| | |
programming question
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#3 29 Days Ago
C++ Syntax (Toggle Plain Text)
#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.
•
•
Join Date: Jan 2008
Posts: 3,818
Reputation:
Solved Threads: 501
0
#4 29 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.
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)
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.
•
•
•
•
C++ Syntax (Toggle Plain Text)
#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.
![]() |
Other Threads in the C++ Forum
- Previous Thread: (beginner) this simple code just errors
- Next Thread: c++ help
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class code coding compile console conversion count data database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






