cannot convert string to string*

Error 1 error C2440: 'initializing' : cannot convert from 'std::string' to 'std::string *'

1
2
3
4
5
6
7
cout<<"Please enter book name:"<<endl;								
cin>>bookName;                     //user enters book name
string *addBookOne=bookName;      //string pointer is created
reservationFile<<*addBookOne;	//  pointer string added to file				

//write book name to reservationFile file
				
Good thing you spotted the error, right? So, uh, if you aren't asking for help why are you posting here?
i'm wondering how to fix it haha
Oh, well. Judging by the error, I will guess that bookName is a string, right? If so, why are you trying to assign a string to a string pointer without referencing it (&)? Also, why do you even need the string pointer at all if you're just going to write it to the file either way? Can't you just do reservationFile << bookName;?
i need to have it displayed "couted" later
Topic archived. No new replies allowed.