Question is:
"Implement a Person class that includes data members to represent name, address, and identification number. The class interface includes methods that provide appropriate access to the data members. Derive a CollegeStudent class and a Professor class from Person. Each of these derived classes should add appropriate data members and methods. Implemente a test client to test the hierarchy. Propose classes to derive from CollegeStudent and Professor. What data members and methods might these derived classes add?"

Does anyone write these program tahnks for your attention...

Ummmm what specifically are you having difficulty with? It is pretty much straightforward OOP...classes and inheritance...

If you haven't learned the subject, thats another issue entirely, in which case I would suggest doing a google search on C++ classes and inheritance, and then posting back here with more specific issues...

Implemente a test client to test the hierarchy. Propose classes to derive from CollegeStudent and Professor. What data members and methods might these derived classes add?"

these part is confused me??

I would assume a test client is simply a driver that tests the various levels of your program...i.e. creating a driver to test the different classes....

And you could propose tons of classes to be derived from CollegeStudent and Professor....there are pretty much no bounds, for example:

You could derive GraduateStudent and UndergraduateStudent from CollegeStudent, which encapsulate the years as a student, years left in the program, program itself, any previous schools attended, current school, etc etc.

You could derive various departments from the professor class, for example MathProfessor derived from Professor, which implements the subjects taught, years as a math prof, tenure, schools taught at, faculty association, etc etc.

Of course, some of these members might already be implemented in the Professor or CollegeStudent class, so you would instead make more specific members...

Really you could go on forever...basically deriving classes as they meet your needs. Essentially, deriving classes allows you to inherit certain properties (from the Person, Professor/CollegeStudent or other base classes), and expand upon others (by adding specifics in the new classes)...

hopefully that helps?

i understood theorycally but i am new at that so, i am struggle with code writing thanks for your all attention :)

might it be like this?

it has error so much but i cant analyze it

#include <iostream>
using namespace std;

class Person{
      char name,adress;
      int id_num;
      public:
             Person();
             void goster();

             };
            Person::goster()
             {
                            cout<<"Name="<<name<<endl;
                            cout<<"Address="<<address<<endl;
                            cout<<"ID Number="<<id_num<<endl;
                            }

                            class CollegeStudent:public Person{
                                  public:
                                         char nameofclass
                                         void goster2();
                                         };
                                         CollegeStudent::goster2();
                                         {
                                                                   cout<<"Name of Class"<<namepfclass<<endl;
                                                                   }

                                  class Professor:public Person{
                                        public:
                                               char dept_of_prof
                                               void goster3();
                                               };


                                        Professor::goster3();
                                        {
                                                             cout<<"Department of Profession"<<dept_of_prof<<endl;
                                                             }
                                                             int main(){
                                                                 int test;
                                                                 Person p1;
                                                                 Professor p2;
                                                                 CollegeStudent p3;
                                                                 cout<<"if you Professor press 1 and College Student press 2"<<endl;
                                                                 cin>>test;
                                                                 if(test==1)
                                                                 {
                                                                            p2.goster3;
                                                                            }
                                                                            if(test==2)
                                                                            {
                                                                                       p3.goster2;
                                                                                       }
                                                                                       return 0;
                                                                                       }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

might it be like this?

it has error so much but i cant analyze it

No it's not. It has a lot of errors in it. (typos, missing constructors, accessing undefined variables). I always say: "if you know it won't work, don't post it.
And always use code-tags when posting code

But nevertheless it may give the OP an idea on how to start.

are there anyone help me like you should write this and that and you shouldnt ..., instead of "DONT POST!" i have tried to do this and search and i cant but i have a homework project and it's urgent...
why do you look down on me?

Just pointing out some very simple errors you have there ...

class CollegeStudent:public Person
{
public:
    char nameofclass [B];[/B]// need a semicolon here
void goster2();
};
CollegeStudent::goster2() // [B];[/B] <- must not have a semicolon there
{
cout<<"Name of Class"<<name[B]o[/B]fclass<<endl; // A typo there, typos are fatal
}

...
if(test==1)
{
    p2.goster3[B]()[/B]; // () needed to make a call to the function
}

it has error so much but i cant analyze it

Don't get overwhelmed by the amount of errors/warnings the compiler produces. Instead, start from the top, working out one error at a time and recompile. Eventually your code compiles ... and you learn the various error codes and their meaning along the way. If you have documentation on your compiler's error codes - refer to that documentation.

At mertucci:

I apologize, I didn't realize you were the original poster.

To make up for my rudeness, I've modded your code, so that it compiles.
I'm not saying it is done yet (I'm not even saying it's great code), you need to add a lot more, but this should get you started:

#include <string>
#include <iostream>
using namespace std;

class Person{
	std::string name,address ;
	int id_num;
public:
	Person()
	{
		name = "blank";
		address= "none yet";
		id_num=0;
	};
	void goster(){
		cout<<"Name="<<name<<endl;
		cout<<"Address="<<address<<endl;
		cout<<"ID Number="<<id_num<<endl;};

};


class CollegeStudent:public Person{
public:
	char nameofclass;
    CollegeStudent()
	{
		nameofclass = 'c';
	}
	void goster2()
	{
		cout<<"Name of Class: "<<nameofclass<<endl;
	}
};


class Professor:public Person{
public:
	char dept_of_prof;
Professor()
{
	dept_of_prof = '0';
}
	void goster3()
	{
		cout<<"Department of Profession: "<<dept_of_prof<<endl;}
	;
};



int main(){
	int test;
	Person p1;
	Professor p2;
	CollegeStudent p3;
	cout<<"if you Professor press 1 and College Student press 2"<<endl;
	cin>>test;
	if(test==1)
	{
		p2.goster3();
	}
	if(test==2)
	{
		p3.goster2();
	}
	cin.ignore();
	cin.get();
	return 0;
}

thanks for all attention brothers
both of you
i'll try to find my other mistakes and probably i'll back to ask if its okay :)

This article has been dead for over six months. Start a new discussion instead.