Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Real World

Can anyone help me with STL?

This topic is 6186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It's for University and I'ma bit stuck. The lecturer must have issues with me because he refuses to answer my emails for help so I'm hoping someone here can help! I have a C++ class that is like this;
class Vertex{

		Vertex () {};					//	Constructor
		~Vertex () {};					//	Destructor
		Vertex& build(int);
		std::vector<Vector4> shape;						 //		Coordinates of object in each space
		std::vector<Vector4> shapeW;
		std::vector<Vector4> shapeV;
		std::vector<Vector4> shapeP;
		std::vector<Vector4> shapeS;

Vertex& Vertex::build(int i)
	return *this;
and a Vector4 class that is like this;

class Vector4{

		float c[4];


	Vector4(float x=0., float y=0., float z=0., float h=1); //default

Vector4::Vector4(float x, float y, float z, float h)
	c[0] = x;
	c[1] = y;
	c[2] = z;
	c[3] = h;
And what I have declared as a global variable is this;
 std::vector<Vertex> object;
Which SHOULD be a C++ vector of vectors. The problem I have is when the code tries to reserve memory for the shape.resize(i); part in the build member fuction I get a Visual C++ Assertation error...
Debug Assertation Failed! Program: filename.cpp File: dbgheap.c Line: 1011 Expression: _CrtIsValidHeapPointer(pUserData) for more information on how your program can cause assertation errors.... etc etc. Abort Retry Ignore
If anyone knows what I'm going on about then PLEASE help me because this is very important. I can't see why the code will not work Thanks. If you need any more information then please let me know! Aarrrrrrrggggghhhhhh!!!!! Edited by - Real World on August 9, 2001 10:43:23 AM

Share this post

Link to post
Share on other sites
It might help if you could explain what the code is actually supposed to do.
Just as a suggestion, try creating a constructor for Vector4 that doesn''t take any arguments (ie Vector4().
I am not sure and am far from documentation but I think that resizeing causes the new elements to be initialised. If there is not a default constructor then it will break. There is a way around this as I think resize can take 2 args.

Share this post

Link to post
Share on other sites
Sorry I didn''t realise I hadn''t already said what it''s meant to do.

I am trying to create, essentially, a vector of vectors. I need to be able to say OK I want aan "object". This object would have 5 vectors inside each reserved with 40 vector4''s Then I could add another object but this one may only have 10 vector4''s of each type. Or another may have 50

So at anypoint in the program I could say object[0].build[50] and the program would reserve 50 vector4''s in the first object.

Does that make sense?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!