0

Edited*

I made a few changes to the code and resolved the major issues. A few of the lines still have these errors, so I think a brief idea of what normally fixes these kinds of errors and what they actually mean should be about all that's left. Thank you guys!

    #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
}
FeeFae
  • 21
  • 6
  • 2
    `int main();` --> `int main() {` – cigien Jun 14 '20 at 04:12
  • 2
    This is a clear case of writing too much code in one go. The mistake you made means that even one line of code would not have compiled. Don't write more than a few lines of code without compiling and testing them. Only when you are satisfied they are working should you write the next few lines of code. Don't make programming more difficult than it already is, – john Jun 14 '20 at 04:19

1 Answers1

1

Your code needs to be in a function.

i.e.

int main() {
  • OMG I didn't even realize that I had put the ; after int main() ... I'm so sorry. I still have other issues with it but that helped a lot of them. Thank you everyone! I just needed another pair of eyes I suppose. – FeeFae Jun 14 '20 at 04:27