0

已编辑*

我对代码进行了一些更改并解决了主要问题。一些行仍然有这些错误,所以我想简要了解通常修复这些错误的方法以及它们的实际含义应该是关于剩下的所有内容。感谢你们!

    #include <iostream>
    #include "RetailItem.h"
    using namespace std;

    int main()
{
    RetailItem *item1 = nullptr;
    RetailItem * item2 = nullptr;
    RetailItem * item3 = nullptr;

    //objects
    item1 = new RetailItem; // c++ requires a type specifier for all declarations
    item2 = new RetailItem; // c++ requires a type specifier for all declarations
    item3 = new RetailItem; // c++ requires a type specifier for all declarations

    //first item
    std::cout << "Please enter the price for the first item." << endl; //expected unqualified-id
    std::cout << "Price must be greater than 0: " << endl; //expected unqualified-id

    cin >> retailPrice; //expected unqualified-id
    while (retailPrice < 0) //loop //expected unqualified-id
    {
        cout << "Price must be greater than 0." << endl;
        cout << "Please try again: " << endl;
        cin >> retailPrice;
    }
    item1 = setPrice(retailPrice); // c++ requires a type specifier for all declarations
    cout << "Please enter number of items in inventory for item 1: " //expected unqualified-id
    cin >> retailUnitsOnHand;
    while(retailUnitsOnHand < 0) //expected unqualified-id
    {
    cout << "Inventory must be greater than 0." << endl;
    cout << "Please enter number of items in inventory for item 1: "
    cin >> retailUnitsOnHand;
    }
    item1 = setUnitsOnHand; // c++ requires a type specifier for all declarations
}
4

1 回答 1

1

您的代码需要在函数中。

IE

int main() {
于 2020-06-14T04:12:22.220 回答