how a class works

please i don't know what's wrong in this class.it is supposed to store employee data and output the emloyee's responsibility. but i don't really know what to do after creating the class so that it outputs responsibility.
class employee
{
char name;
char department;
float salary;
int age;
public:
void responsibility();
float earnings();
};
int main()
{
if employee.obj=001 // employee obj<=20
cout<<"an employee is a teaching staff"<< endl;
else
cout<<"an employee is an adminstrative staff"<< endl;
void employee::responsibility();
employee joe; joe.responsibility();
};

Last edited on
Hey buddy,
That code looks a bit broken, not sure where you got it from.
Basically a class is a way to represent an object in programming.
To declare a class the syntax is:

class ObjectIdentifier
{
\\data members and functions
};

There is a great section on classes in the tutorial.
Some things to remember
1)By default anything declared in the class without a access-level specifier, private:, protected, or public: is private by default.
2)If you do not write your own constructors/destructors, then C++ provides blank empty ones which do no assigning to data members.
Last edited on
@d4rkz3ro. thanks for the tips. actually it's an example given by lecturer. just checking it out

Last edited on
Topic archived. No new replies allowed.