I am getting this error when I create a function that attempts to use a string as an argument list than cout that string.
this particular function is designed to change a char variable used to repeat a program.
Error 2 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
it says I think that cout cannot accept std::string a. any ideas?
thanks for the reply cire had it right. this is my code so far and well try and run it and see what happens it does not seem to be functioning correctly. it runs through the while loop without stopping and throws some exceptions that arent intended.. i am on windows 7 and visual studios 12
this is the main.cpp
#include<iostream>
#include<vector>
#include<algorithm> //reverse function
#include<Windows.h>
#include"vector_Utilities.h" //char_Input(vector.push_back routine)... vector_Iterator(print vector routine)...
//reverse1(pass by value)... reverse2(pass by reference)
//elipses(sleep function and cout ".")
usingnamespace std;
int main()
{
cout<<"Vector data reversal program.\n";
char repeat='y';
while(repeat==('y')||('Y'))
{
try
{
vector<double> reversed, original;
cout<<"Enter data to be reversed.\n";
char_Input(original);
if(original.size()==((0)||(1)))
{ throw vector_Size_error();}
cout<<"Calling reverse function by value";
elipses();
reversed=reverse1(original);
vector_Iterator(reversed);
cout<<"Original vector (unchanged).\n";
vector_Iterator(original);
Sleep(1000);
cout<<"Calling reverse function by reference";
elipses();
reverse2(original);
vector_Iterator(original);
program_Repeat("Would you like to reverse more data? (Y/N).",repeat);
}
catch(vector_Size_error)
{
cout<<"Error: The size of the vector is either null or one and cannot be reversed.\n";
program_Repeat("Would you like to try again?",repeat);
}
catch(repeat_Variable_error)
{
cout<<"Error: The request to reverse more data was not answered correctly.\n";
program_Repeat("Type 'y' to restart or 'n' to terminate process.",repeat);
}
}
return 0;
}
Aside from that, there is no way for program_Repeat to affect the variable named repeat in your main function. Why do you pass in b?
You have the same sort of comparison problem in line 21 of your main function.
In char_Input you rely on std::cin entering an error state to terminate the input extraction loop, but you never clear the error state or remove the offending input, so all subsequent attempts to extract data from std::cin will fail.