Question: in c + + The copy constructor is a constructor which creates an object by initializing it with an object of the same class. Given
in c The copy constructor is a constructor which creates an object by initializing it with an object of the same class.
Given a 'class ProblemSolution', create a copy constructor which will copy all data members of the existing object and display it
Input
where,
First line contains an integer x
Second line contains an integer y
Output
Assume that,
x an y are integers within the range to
#include
using namespace std;
class ProblemSolution
private:
int x;
int y;
public:
ProblemSolution;
void setValuesint xint y
this x x;
this y y;
;
int main
int xy;
cin x;
cin y;
ProblemSolution problemSolution;
problemSolution.setValuesxy;
ProblemSolution problemSolutionCopyproblemSolution;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
