944,138 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 395
  • C++ RSS
Oct 30th, 2009
0

programming question

Expand 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
razo is offline Offline
5 posts
since Oct 2009
Oct 30th, 2009
-7
Re: programming question
we don't do homework for you, but we will help you if you have specific questions. Post what you have tried.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Oct 31st, 2009
0
Re: programming question
C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
razo is offline Offline
5 posts
since Oct 2009
Oct 31st, 2009
0
Re: programming question
Click to Expand / Collapse  Quote originally posted by razo ...
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:

C++ Syntax (Toggle Plain Text)
  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.

Click to Expand / Collapse  Quote originally posted by razo ...
C++ Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: (beginner) this simple code just errors
Next Thread in C++ Forum Timeline: c++ help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC