我是c ++的新手,所以不确定我错过了它的地方,因为只有描述不允许执行代码,希望能对您有所帮助
InventoryItem (char const *desc, double c, int u)
{
description = new char[strlen (desc) + 100];
strcpy (description, desc);
~InventoryItem ()
{
delete[]description;
}
const char *getDescription () const
{
return description;
}
cout << setprecision (2) << fixed << showpoint;
cout < "Item Description:" << stock.getDescription ()<< endl;
答案 0 :(得分:1)
您在应该有cout <
的最后一行写了cout <<
。
我假设消息说operator <<
; C ++将其解释为将cout
与"Item description:" << stock.getDescription() << endl
进行比较,但是"Item description:" << stock.getDescription()"
本身没有任何意义,因此它给出了一个错误。