Sign in to follow this  

C++: Vector Problem

This topic is 4841 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

Hello, what does this error message mean? I thought vector was a container and the type would be of the 'tMaterialInfo' struct. "74 'vector' is used as a type, but is not defined as a type."
#include <vector>
using namespace std;
...
struct tMaterialInfo
{
	char  strName[255];
	char  strFile[255];
	BYTE  color[3];
	int   texureId;
	float uTile;
	float vTile;
	float uOffset;
	float vOffset;
} ;
...
vector<tMaterialInfo> pMaterials; //This is line 74

I am using Dev C++ ver 4.9.9.0b, thank you.

Share this post


Link to post
Share on other sites
Thanks for the quick replies.

I decided to try to explicity declare the pathname with the vector, #include <c++\vector> or #include <c++/vector>, tried both - I've seen it one way and the other so I'm not sure.

The error messages that came up next were:
bits/functexcept.h: No such file or directory.
bits/stl_algobase.h: No such file or directory.
and so on...

I think those are all header files that are declared within the vector file.

If I compiled it again with those messages, it compiles through and my executable augments in size to indicate that the code I entered has been added but if I choose to rebuild all, then all those error messages manifest again.

I probably should just take it off my code this time, since the program is for a school project, and spend more time learning more about templates.

Share this post


Link to post
Share on other sites
I believe it is because tMaterialInfo isn't anything. struct tMaterialInfo is, on the other hand. Try either of these:

1) change the name of struct tMaterialInfo to "typedef struct _tMaterialInfo{ ... } tMaterialInfo;

2) change the vector to:
vector<struct tMaterialInfo> pMaterials;


Either of those should work.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by visage
I believe it is because tMaterialInfo isn't anything. struct tMaterialInfo is, on the other hand. Try either of these:

1) change the name of struct tMaterialInfo to "typedef struct _tMaterialInfo{ ... } tMaterialInfo;

2) change the vector to:
vector pMaterials;


Either of those should work.
This is NOT C. In C++ you don't have to do like that. The way he does is just fine.

Share this post


Link to post
Share on other sites
I guess this one was one of those development mysteries because I could use the variables without any further problems from the compiler.

My program performs what it is suppose to regardless of that error. The first compile does not create the program because of the error but the second compile after that, try compiling again, compiles through.

I'll try digging through the code after I'm satisfied with all the other aspects since it will only be used in a school project; yes I will run it on my teacher's computer too to make sure it works.

Thank you everyone.

Share this post


Link to post
Share on other sites
whoops! See, this is why I should be doing homework and not trolling the pages of gamedev...
But as a side note: I tried it in with MingGW and it compiled fine.


Sorry for my little mess up before!
[embarrass]

Share this post


Link to post
Share on other sites

This topic is 4841 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this