Public Group

# C++: Vector Problem

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

## 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 on other sites
The snippet you posted looks alright.

I think, there must be some scope error in the "..." parts of your source.. Is this the only error you're getting?

Oxyd

##### Share on other sites
I tried this out too for you on both gcc and VisualStudio and everything worked fine. There must be something else going on in the ... parts of your code. :)

##### 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 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 on other sites
Quote:
 Original post by visageI 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 on other sites
The AP above was me. I meant to say that the original posters code is C++ and you don't have to typedef structs like you do in C.

##### 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 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]

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 42
• ### Forum Statistics

• Total Topics
632635
• Total Posts
3007559
• ### Who's Online (See full list)

There are no registered users currently online

×