|
-
March 7th, 2010, 10:20 PM
#1
unable to output string?
Code:
void write_on_paper(string words)
{
if (InkLevelPercent <=0)
{
cout << "Oops! Out of ink!" << endl;
}
else
{
cout << words << endl;
InkLevelPercent = InkLevelPercent - words.length();
}
}
1>c:\users\noah\documents\visual studio 2008\projects\objsnclasses\objsnclasses\pen.h(40) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
The error code is referring to I'm still learning C++ and this is an example from the book. But it won't compile. can anybody help please? thanks in advance.
-
March 7th, 2010, 10:28 PM
#2
Re: unable to output string?
Nevermind i found my issue my compiler doesn't include string in the std namespace. i needed to include <string>
-
March 7th, 2010, 10:29 PM
#3
Re: unable to output string?
What header files did you include?
Those functions and classes are declared in their appropriate #include files, so that code is not complete unless you post what files are included.
Regards,
Paul McKenzie
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
|