Monday, December 1, 2008

placement c++ programming language Question

1) Determine the output of the 'C++' Codelet.
class base
{  
public : 
out() 
cout<<"base ";  
}  
};
class deri{ 
public : out() 
cout<<"deri "; 
}   
};
void main()
{ deri dp[3];
base *bp = (base*)dp;
for (int i=0; i<3;i++)
(bp++)->out();
}


2) Justify the use of virtual constructors and destructors in C++.


3) Each C++ object possesses the 4 member fns,(which can be declared by the programmer explicitly or by the implementation if they are not available). What are those 4 functions?


4) What is wrong with this class declaration?
class something
{
char *str;
public:
  something(){
  st = new char[10]; }
 ~something()
 {
  delete str; 
 }
};

5) Inheritance is also known as -------- relationship. Containership as   ________ relationship.

6)  When is it necessary to use member-wise initialization list  (also known as header initialization list) in C++?

7) Which is the only operator in C++ which can be overloaded but NOT inherited.

8) Is there anything wrong with this C++ class declaration?
class temp
{
 int value1; 
 mutable int value2;
 public :
  void fun(int val) 
const{
  ((temp*) this)->value1 = 10;
  value2 = 10;
  }
};
 

No comments:

Post a Comment

Thanks to given comments.......

My Blog List