I'm trying to design a construct that can check for errors in input, so I wrote two boolean functions in a test program whose parameters are string references. I was hoping my if statement would evaluate the first function- changing part of word, then evaluate the second function- changing word again, and finally evaluate the && to see whether print. My code won't run, however, and the error says that no operand matches the << operator for cout, when I'm trying to output the code. My code is can explain better than I. Could someone please explain why this won't work? I'm using Visual Studio 2012.
#include <iostream>
using namespace std;
bool changeString1(string &word){
word[0]='a';
return word[1]=='b';
}
bool changeString2(string &word){
word[2]='c';
return word[3]=='d';
}
int main(){
cout << "hello" << endl;
string word("cbad");
if(changeString1(word) && changeString2(word)){
cout << word << endl;
}
system("Pause");
return 0;
}