programming question

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

Join Date: Oct 2009
Posts: 5
Reputation: razo is an unknown quantity at this point 
Solved Threads: 0
razo razo is offline Offline
Newbie Poster

programming question

 
0
  #1
30 Days Ago
hello, i need ur help..


define a CLASS PERSON TYPE that does:

a. set the first name only.

b. set the last name only.

c. store and set the middle name.

d. check whether a given first name is the same as the first name of this person.

e.check whether a given first name is the same as the first name of this person,

write the definition of the member function to implement the operations for this class.also, write a program to test various operations on this class.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,401
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning
 
-7
  #2
30 Days Ago
we don't do homework for you, but we will help you if you have specific questions. Post what you have tried.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 5
Reputation: razo is an unknown quantity at this point 
Solved Threads: 0
razo razo is offline Offline
Newbie Poster
 
0
  #3
29 Days Ago
  1. #include<string>
  2. using namespace std;
  3.  
  4. class persontype
  5. {
  6. public:
  7. void setname(string first);
  8. void setname(string last);
  9. void setname(string middle);
  10.  
  11. private:
  12. string middle name;
  13.  
  14. };


is the beginig true?

this is what i knew..i dont know how to complete,if anyone can help.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,818
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #4
29 Days Ago
Originally Posted by razo View Post
hello, i need ur help..


define a CLASS PERSON TYPE that does:

a. set the first name only.

b. set the last name only.

c. store and set the middle name.

d. check whether a given first name is the same as the first name of this person.

e.check whether a given first name is the same as the first name of this person,

write the definition of the member function to implement the operations for this class.also, write a program to test various operations on this class.

a, b, and c. What's the difference between "set" and "store and set"? I assume you want the normal "set" and "get" function for each of the three private variables. So at minimum, three private variables, six public functions, and you should probably add at least one public null constructor, even if it's empty, but I suppose that's somewhat optional. That's normally the way it's done. Here's something to get you started:

  1. class personType
  2. {
  3. public:
  4. void setfirstNameame(string first);
  5. void setlastName(string last);
  6. void setmiddleName(string middle);
  7. string getfirstName ();
  8. string getlastName ();
  9. string getmiddleName ();
  10.  
  11.  
  12. private:
  13. string firstName;
  14. string middleName;
  15. string lastName;
  16.  
  17. };

Note that the "set" functions are void and take a parameter. The "get" functions are not void and don't take a parameter. All are public. All variables are private. There are no spaces in the variable names.

Originally Posted by razo View Post
  1. #include<string>
  2. using namespace std;
  3.  
  4. class persontype
  5. {
  6. public:
  7. void setname(string first);
  8. void setname(string last);
  9. void setname(string middle);
  10.  
  11. private:
  12. string middle name;
  13.  
  14. };


is the beginig true?

this is what i knew..i dont know how to complete,if anyone can help.

See my earlier post above. No spaces in the variable name and you'll get an error for having three functions with the same name, all of which take a single string. Note that my functions all have different names.
Reply With Quote Quick reply to this message  
Reply

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