Topic Wise SP Question Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
CPP: Topicwise Exam Question: copy-constructor
Q.1  02A  
Copy Constructor Definition and Example 2

What is a copy constructor? Give a suitable example in C++ to illustrate with its definition within a class and a declaration of an object with the help of it .

CBSE12D-2015

Q.2  02B  
OOPs Concept Identification and Writing Object Declaration Statements 2

Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.

class TEST
{
  long TCode;
  char TTitle[20];
  float Score;
public:
  TEST()    //Member Function 1
  {
    TCode=100;strcpy(TTitle,”FIRST Test”);Score=0;
  }
  TEST(TEST &T)    //Member Function 2
  {
    TCode=E.TCode+1;
    strcpy(TTitle,T.TTitle);
    Score=T.Score;
   }
};
void main()
{
___________________     //Statement 1
___________________     //Statement 2
}

(i) Which Object Oriented Programming feature is illustrated by the Member Function 1 and Member Function 2 together in the class TEST?

(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively.

CBSE12A-2017

Q.3  02A  
Copy Constructor Definition and Example 2

What is a copy constructor? Give a suitable example in C++ to illustrate with its definition within a class and a declaration of an object with the help of it.

CBSE12A-2015