二进制“ operator”类型的“ const char [18]”和“ const char *”类型无效的操作数

时间:2019-09-24 03:01:19

标签: c++

我是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;

1 个答案:

答案 0 :(得分:1)

您在应该有cout <的最后一行写了cout <<

我假设消息说operator <<; C ++将其解释为将cout"Item description:" << stock.getDescription() << endl进行比较,但是"Item description:" << stock.getDescription()"本身没有任何意义,因此它给出了一个错误。