Question
class Person{ private: int age; int weight; public: }; int main(){ Person p[5]; Person q[5]; Define member functions like a default constructor to initialize the
class Person{
private:
int age;
int weight;
public:
};
int main(){
Person p[5];
Person q[5];
Define member functions like a default constructor to initialize the age and weight of 5 objects of Person p and q. (Marks 2)
Print the age and weight of 5 objects of Person p. (Marks 3)
Define a setPerson member function to initialize the age of 5 objects of Person p as say age =25 and weight 200 Ibs
Write a getFunction to output all the ages and weight of 5 objects of Person p
Initialize using anonymous objects all the objects of q with different values of age and weight
Make each of the objects of p equal to the objects of q
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started