C++ Write the definition for a class where you could be an object in the class.
ID: 3812974 • Letter: C
Question
C++
Write the definition for a class where you could be an object in the class. So your name would end up being a variable name if someone were to use this class. Your class must have at least 2 member variables and at least one member function with its corresponding definition.
You don't need to actually write an executable program, just write a class that someone else could use to write a program. You should try to imagine a program that would use your class while writing the class definition.
Explanation / Answer
Class and Object
A Class is a blue print or prototype for a particular context (Project) in real world. An object is the way of giving specification of data in the class to make it real world entity.
Example:
Project is a real world object in which it contains Project ID, Project Name, Duration, Technology, Team which handles that and client who needs it to be delivered. It is a model for any kind of project specification in real world software projects.It contains collection of Attributes and functions OR data members and member functions.
Attributes are: projectId, projectName, technology, team, duration and Client
Operations are: setProjectDetails() and getProjectDetails()
Example:
class Project {
private:
int projectId;
char projectName[30];
char projectClient[50';
int duration;
char technology[50];
char team[8][60];
public:
public void setProjectDetails(int projectId,char projectName[50],int duration){
}
public Project getProjectDetails( ){
}
};
Creating object for the class Project is just allocating memory for the object in main memory.
Like, Project project;
project.setProjectDetails(101,"Java",.....)
Project pData = project.getProjectDetails();
setProjectDetails() function explains about the way of assigning details to Project object and getProjectDetails() is used to return Project object.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.