where is the error??

X

xhy_China

Hello:
This evening I make a cpp file(it's a sample of c++
primer,chapter 3,string.cpp).The outline of it is below:
#include <iostream>
// line 1

class string;
istream& operator>>(istream&,string&); //
line 4
ostream& operator<<(ostream&,const string&);

class string
{
public:
string();
virtual ~string();
};

string::string()
{
//Do something
}

string::~string()
{
//Do something
}

istream& operator>>(istream& io,string& s)
{
//Do something
}

ostream& operator<<(ostream& os,string& s)
{
//Do something
}

int main()
{
//Do something
}

After I run the program,compiler tell me that missing ";"
before "&" in line 4,also line 5. I dont
know why(I use VC++ 6.0)??? Then I download the code of the book to
run,but it caused the same
error! why? How to modify the code???

Thx
 
T

Thomas Tutone

xhy_China said:
Hello:
This evening I make a cpp file(it's a sample of c++
primer,chapter 3,string.cpp).The outline of it is below:
#include <iostream>

Add the following here:

using std::istream;
using std::eek:stream;

Remember, anything from the standard library is in namespace std, so
you must qualify the names or put in a using directive.

Best regards,

Tom
 
X

xhy_China

Thx ! The problem has been solved!


Thomas said:
Add the following here:

using std::istream;
using std::eek:stream;

Remember, anything from the standard library is in namespace std, so
you must qualify the names or put in a using directive.

Best regards,

Tom
 
N

Nate Barney

Thomas said:
Add the following here:

using std::istream;
using std::eek:stream;

Remember, anything from the standard library is in namespace std, so
you must qualify the names or put in a using directive.

Or using declarations, like you've done here. ;-)

Nate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top