A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

Discussion Forum

Que. What will be the output of the following code?
Class A
{ 
 int i; 
 public : A(int n)
 { 
  i=n; cout<<”inside constructor ”;
 } 
 ~A()
 {
  cout<<”destroying  ”<<i;
 }
 void seti(int n)
 {
  i=n;
 }
 int geti()
 {
  return I;
 }
};
void t(A ob)
{ 
 cout<<”something ”;
}
int main()
{
 A a(1);
 t(a);
 cout<<”this is i in main ”;
 cout<<a.geti();
}
a. inside constructor something destroying 2this is i in main destroying 1
b. inside constructor something this is i in main destroying 1
c. inside constructor something destroying 2this is i in main
d. something destroying 2this is i in main destroying 1
Answer:inside constructor something destroying 2this is i in main destroying 1
Confused About the Answer? Ask for Details Here
Know Explanation? Add it Here