how to fix compile error

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 2
Reputation: hyliandanny is an unknown quantity at this point 
Solved Threads: 0
hyliandanny hyliandanny is offline Offline
Newbie Poster

Re: MS Visual++ 6.0 - Error C2146, C2501 ...

 
0
  #1
Jul 16th, 2008
Hello, everyone. I've got a compiler error popping up for this class:

  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Stage
  5. {
  6. private:
  7. string var;
  8. public:
  9. Stage();
  10. Stage(int num_of_items);
  11. };

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?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 973
Reputation: Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough 
Solved Threads: 107
Alex Edwards's Avatar
Alex Edwards Alex Edwards is offline Offline
Posting Shark

Re: MS Visual++ 6.0 - Error C2146, C2501 ...

 
1
  #2
Jul 16th, 2008
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;
Last edited by Alex Edwards; Jul 16th, 2008 at 9:53 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC