Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > where is the error??

Reply
Thread Tools

where is the error??

 
 
xhy_China
Guest
Posts: n/a
 
      10-13-2006
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

 
Reply With Quote
 
 
 
 
Thomas Tutone
Guest
Posts: n/a
 
      10-13-2006

xhy_China wrote:
> 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: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

 
Reply With Quote
 
 
 
 
xhy_China
Guest
Posts: n/a
 
      10-13-2006
Thx ! The problem has been solved!


Thomas Tutone wrote:
> xhy_China wrote:
> > 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: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


 
Reply With Quote
 
Nate Barney
Guest
Posts: n/a
 
      10-13-2006
Thomas Tutone wrote:
> Add the following here:
>
> using std::istream;
> using std: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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments