I haven't programmed in sometime and am rusty. I was never an expert either. I know my code has a simple error but I can't figure out what it is. I was practicing coding when I couldn't determine why the class constructor wasn't working as intended.

#include <iostream>                  
using std::cout;

class CBus
{
public:
    int year;
    char *model;
    char *make;

    CBus(int a, char *b, char *c);
    bool operator>(CBus &aBus)const;
};

CBus::CBus(int a = 1995, char *b = Sedan, char *c = Mazda)
{
    year = a;
    model = b;
    make = c;
}

bool CBus::operator>(CBus &aBus)const
{
    return this->year > aBus.year;
}


int main()
{

    CBus John(1998, Camry, Toyota);
    CBus Pam(2012, Sedan, Toyota);

    cout << "  "  <<  (Pam>(John));
}

I underlined and bold the words that intellisense put red lines under in my compiler.

If you mean those underlined variables to be strings, you have to put " around them.

CBus::CBus(int a = 1995, char *b = "Sedan", char *c = "Mazda")

I knew I forgot something. I'll remember to use ' for char. Thanks for the quick response.

Also, use const char* for the make and model. Most compilers will give you an error using string literals for a non-const char pointer.

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.