954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to fix compile error

Hello, everyone. I've got a compiler error popping up for this class:

#include <iostream>
#include <string>

class Stage
{
private:
	string var;
public:
	Stage();
	Stage(int num_of_items);
};


The error is:

error C2146: syntax error : missing ';' before identifier 'var'

The funny thing is that if I remove the line "string var", it works fine. Any ideas?

hyliandanny
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

It could be that string is defined in namespace std, which you forgot to declare that you are using.

Either that or declare--


using std::string

or--
std::string var;

Alex Edwards
Posting Shark
972 posts since Jun 2008
Reputation Points: 392
Solved Threads: 109
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You