Please Help Me abuot C++ Problem :icon_question:

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 16
Reputation: mertucci is an unknown quantity at this point 
Solved Threads: 0
mertucci mertucci is offline Offline
Newbie Poster

Please Help Me abuot C++ Problem :icon_question:

 
0
  #1
May 14th, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 87
Reputation: n1337 is on a distinguished road 
Solved Threads: 8
n1337 n1337 is offline Offline
Junior Poster in Training

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #2
May 14th, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 16
Reputation: mertucci is an unknown quantity at this point 
Solved Threads: 0
mertucci mertucci is offline Offline
Newbie Poster

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #3
May 14th, 2008
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??
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 87
Reputation: n1337 is on a distinguished road 
Solved Threads: 8
n1337 n1337 is offline Offline
Junior Poster in Training

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #4
May 14th, 2008
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?
Last edited by n1337; May 14th, 2008 at 6:51 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 16
Reputation: mertucci is an unknown quantity at this point 
Solved Threads: 0
mertucci mertucci is offline Offline
Newbie Poster

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #5
May 14th, 2008
i understood theorycally but i am new at that so, i am struggle with code writing thanks for your all attention
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 16
Reputation: mertucci is an unknown quantity at this point 
Solved Threads: 0
mertucci mertucci is offline Offline
Newbie Poster

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #6
May 14th, 2008
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;
}
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,847
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 298
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #7
May 15th, 2008
Originally Posted by mertucci View Post
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 16
Reputation: mertucci is an unknown quantity at this point 
Solved Threads: 0
mertucci mertucci is offline Offline
Newbie Poster

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #8
May 15th, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 978
Reputation: mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice 
Solved Threads: 208
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #9
May 15th, 2008
Just pointing out some very simple errors you have there ...
class CollegeStudent:public Person
{
public:
    char nameofclass ;// need a semicolon here
void goster2();
};
CollegeStudent::goster2() // ; <- must not have a semicolon there
{
cout<<"Name of Class"<<nameofclass<<endl; // A typo there, typos are fatal
}

...
if(test==1)
{
    p2.goster3(); // () 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.
Last edited by mitrmkar; May 15th, 2008 at 7:50 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,847
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 298
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: Please Help Me abuot C++ Problem :icon_question:

 
0
  #10
May 15th, 2008
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:
  1.  
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class Person{
  7. std::string name,address ;
  8. int id_num;
  9. public:
  10. Person()
  11. {
  12. name = "blank";
  13. address= "none yet";
  14. id_num=0;
  15. };
  16. void goster(){
  17. cout<<"Name="<<name<<endl;
  18. cout<<"Address="<<address<<endl;
  19. cout<<"ID Number="<<id_num<<endl;};
  20.  
  21. };
  22.  
  23.  
  24. class CollegeStudent:public Person{
  25. public:
  26. char nameofclass;
  27. CollegeStudent()
  28. {
  29. nameofclass = 'c';
  30. }
  31. void goster2()
  32. {
  33. cout<<"Name of Class: "<<nameofclass<<endl;
  34. }
  35. };
  36.  
  37.  
  38. class Professor:public Person{
  39. public:
  40. char dept_of_prof;
  41. Professor()
  42. {
  43. dept_of_prof = '0';
  44. }
  45. void goster3()
  46. {
  47. cout<<"Department of Profession: "<<dept_of_prof<<endl;}
  48. ;
  49. };
  50.  
  51.  
  52.  
  53. int main(){
  54. int test;
  55. Person p1;
  56. Professor p2;
  57. CollegeStudent p3;
  58. cout<<"if you Professor press 1 and College Student press 2"<<endl;
  59. cin>>test;
  60. if(test==1)
  61. {
  62. p2.goster3();
  63. }
  64. if(test==2)
  65. {
  66. p3.goster2();
  67. }
  68. cin.ignore();
  69. cin.get();
  70. return 0;
  71. }
Last edited by niek_e; May 15th, 2008 at 8:06 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC