This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
Error with overloading operators
Post Flair (click to view more posts with a particular flair)
Post Body
int main(int argc, char** argv) {
int userChoice;
while(userChoice != 4)
{
cout << "1.Add a book to yout cart" << endl;
cout << "2.Delete a book from your cart" << endl;
cout << "3.Display the books in your cart" <<endl;
cout << "4.Exit" << endl;
cout << endl << "Your choice: ";
cin >> userChoice;
if(userChoice == 1)
{
string title;
cout <<"Title to add: ";
cin >> title;
Book mybook(title);
mybook = title;
}
if(userChoice == 3){
Cart mycart;
mycart.display();
}
}
}
using namespace std;
Cart& Cart::operator =(Book& obj){
v.push_back(obj);
return *this;
}
Book::Book(std::string bookTitle){
setBookTitle(bookTitle);
This is my first time with overloaded operators and I feel like this is as far as I can get. I was supposed to prompt for a book title and add it to a vector using the compound operator =. I am getting a no-match operator error. Any help is appreciated. Thanks!
Author
Account Strength
100%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
7,063
Link Karma
2,992
Comment Karma
3,871
Profile updated: 2 days ago
Posts updated: 1 year ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/cpp_questio...