-
August 8th, 2010, 12:01 AM
#1
rmc/rmc.h:18: error: ISO C++ forbids declaration of `rules' with no type
Code:
#ifndef _RMC_H
#define _RMC_H
#include <cstdio>
#include <string>
#include <vector>
class RMC {
std::vector <std::string> rules;
rules.push_back("This is a string");
};
#endif /* _RMC_H */
I have worked on this for a while. It works when I put it in the main() function, but never in classes. Why? Any help sure is appreciated!
-
August 8th, 2010, 02:10 AM
#2
Re: rmc/rmc.h:18: error: ISO C++ forbids declaration of `rules' with no type
This statement should be placed in a function:
Code:
rules.push_back("This is a string");
It does not belong in a class definition (unless it is within a function) because it is not some declaration of a member variable, member function, etc.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|