#include <iostream>
#include <string>
using namespace std;
class BookData
{
string Title;
int Qty;
public:
void setTitle(string in_title) { Title = in_title;}
string setQty(int in_qty) { Qty = in_qty; }
string getTitle() { return Title; }
int getQty() { return Qty; }
};
int main()
{
BookData book;
book.setTitle("Starting Out with C++");
book.setQty(10);
cout << "Title is " << book.getTitle() << ".\n\n";
cout << "Quantity is " << book.getQty() << ".\n\n";
return 0;
}
When I compile all I get is an empty console. Any suggestions?
Change the return type of BookData::setQty() from string to void.
Without this change, it should still work fine. On my Linux machine, it crashes when setQty() is called with a return type of string and no string being returned.