[英]invalid operands of types ‘const char [18]’ and ‘const char*’ to binary ‘operator
Im new to c++ so not sure where i miss out its as only the description not allowing execute the code, hope able to help我是 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;
You wrote cout <
on the last line, where you should have cout <<
.你在最后一行写了cout <
,你应该有cout <<
。
I'm assuming the message said operator <<
;我假设消息说operator <<
; C++ interpreted it as comparing cout
to "Item description:" << stock.getDescription() << endl
, but "Item description:" << stock.getDescription()"
by itself doesn't make sense, so it gave an error. C++ 将其解释为将cout
与"Item description:" << stock.getDescription() << endl
进行比较,但"Item description:" << stock.getDescription()"
本身没有意义,因此它给出了错误.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.