Hi, I'm having an error when trying to output a string to a file and basic output.
error is as follows:
K:\C++2\Final Project\FactFinder\Birthday.cpp(530) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no ac
ceptable conversion)
K:\C++2\Final Project\FactFinder\Birthday.cpp(535) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no ac
ceptable conversion)the program is rather lengthy so ill just paste the function and include statements.
CODE
#include "Birthday.h"
#include <iostream.h>
#include <string>
void Birthday::bStoneIOfunc()
{
int iChoice = 0;
int oChoice = 0;
ofstream output;
cout << "How Would You Like To Collect Input?\n";
cout << "1. Input From File.\n";
cout << "2. Input to Screen.\n";
cout << "3. Exit.\n";
cin >> iChoice;
switch(iChoice)
{
case 1:
fileInput();
break;
case 2:
cout << "Please Enter the Day You Were Born\n";
cin >> d;
cout << "Please Enter Your Birth Month\n";
cin >> m;
setDay(d);
setMonth(m);
break;
case 3:
exit(0);
break;
}
cout << "What Would You Like to do With Your Output?\n";
cout << "1. Output to File.\n";
cout << "2. Ouput to Screen.\n";
cout << "3. Exit.\n";
cin >> oChoice;
string bStone = birthStone();
switch(oChoice)
{
case 1:
cout << "Opening the output File.\n The Output File Will be Called facts.txt";
output.open("facts.txt");
output << "Your Birthstone is: " << bStone << "\n";
output.close();
cout << "File Saved!\n";
break;
case 2:
cout << "Your Birthstone is: " << bStone << "\n";
break;
case 3:
exit(0);
break;
}
}
The errors are at lines:
output << "Your Birthstone is: " << bStone << "\n"; AND
cout << "Your Birthstone is: " << bStone << "\n";I have no clue why it's not letting me output my string. Fast Reply Is greatly Appreciated as due date is rapidly approaching!
This post has been edited by jayman9: 19 Nov, 2007 - 11:45 PM