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.

#include<string>
using namespace std;

class persontype
{
public:
void setname(string first);
void setname(string last);
void setname(string middle);
 
private:
string middle name;

};

is the beginig true?

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

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:

class personType
{
public:
void setfirstNameame(string first);
void setlastName(string last);
void setmiddleName(string middle);
string getfirstName ();
string getlastName ();
string getmiddleName ();

 
private:
string firstName;
string middleName;
string lastName;

};

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.

#include<string>
using namespace std;

class persontype
{
public:
void setname(string first);
void setname(string last);
void setname(string middle);
 
private:
string middle name;

};

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.

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