I need a little bit of help here. I'm new to C++ Classes.
There are some errors which I do not know how to troubleshoot.

The error of "Declaration terminated incorrectly" for line 6 and 7.
Multiple errors of "Type name expected". Why is that?
Multiple errors of "Declaration missing ;". Why is that?

I'm grateful if anyone could guide me here.

    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    class Address
    {
    public:
    Address(int h, string st, int appt, string c, string s, string pc);
    Address(int h, string st, string c, string s, string pc);
    bool comes_before(Address a) const;
    void print() const;
    private:
    int house_number;
    string street;
    int apartment_number;
    string city;
    string state;
    string postal_code;
    };
    Address::Address(int h, string st, int appt, string c, string s, string pc)
    {
    // initialization of the variables
    house_number = h;
    street = st;
    apartment_number = appt;
    city = c;
    state = s;
    postal_code = pc;
    }
    Address::Address(int h, string st, string c, string s, string pc)
    {
    // initialization of the variables
    house_number = h;
    street = st;
    city = c;
    state = s;
    postal_code = pc;
    }
    void Address::print()const
    {
    cout << house_number << " " << street;
    if (apartment_number > 0 )
    cout << ", #" << apartment_number << endl;
    cout << city << ", " << state << ", " << postal_code << endl;
    }
    bool Address::comes_before( Address other)const
    {
    return postal_code < other.postal_code;
    }
    int main()
    {
    //creating an object of 'Address' for a house
    Address aHouse(100, "N.University Dr.", "Edmond", "OK", 73034);
    //creating another object of 'Address' for an apartment
    Address anApartment(201, "N.E. 89th St.", 305, "Oklahoma City", "OK", 73134);
    cout << " Comparing Address\n\n";
    a.House.print();
    cout << "\nwith address\n\n";
    anApartment.print();
    if(a.House.comes_before(anApartment))
    cout << "\nThe HOUSE address comes before the APARTMENT address\n";
    else
    cout << "\nThe HOUSE address does o come before the APARTMENT address\n";
    // comparing again
    if (anApartment.comes_before(aHouse))
    cout << " \nThe APARTMENT address comes before the HOUSE address\n";
    else
    cout << " \nThe APARTMENT address does not come before the HOUSE address\n";
    return 0

You need to include <string> header file. Also, change <stdlib.h> to <cstdlib>

I've changed the header as you suggested. But, the errors still exist. Can you guide me on that?

what compiler are you using? Line 54 is incorrct because the last parameter is supposed to be std::string not an int.

Line 52 & 54 : constructor has last argument as sting not an integer. Check the arguments of calling statement and constructor declaration.

Line 56 & 59 : There is nothing as a.House, it should be aHouse.

And atlast there is no ending brace after return 0 (line 68) and no ' ; 'after return 0.

Make these changes and see if it works or not.

And atlast there is no ending brace after return 0 (line 68) and no ' ; 'after return 0.

Proper formatting would have shown you this error in seconds.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.