Conceptuals

C++

1. Name the four kind of functions that a c++ compiler is able to provide by default.

Ans:	Constructor, Copy Constructor, Assignment operator, Destructor

2. Name the four operators that a C++ programmer cannot overload.

Ans:	dot, scope resolution, sizeof operator, ternary conditional 	operator

3. What is passed to and what is returned by the put-to operator in the following case :
		cout<<1.0 ;

Ans:	<< receives an ostream object by reference and a double by value and returns the ostream object by reference.

4.If both the following statements in the code below are accepted by the compiler, then what is the possible relation between a,line and circle?

void main()
{
	.
	.
	.
	a = new line ;
	.
	.
	.
	a = new circle ;
	.
	.
	.
}

Ans:	a is an object of a base class from which the classes line and circle are derived.
		
C:

1.What should p be declared as so that the following assigment is error free?What is the value of sizeof(*p)?
	int a[3][4] ;
	.
	.
	.
	p = a ;

Ans:	int (*p)[4] ;
	sizeof(p) is 8.

2.The error reported by the compiler when we write 
	++a++ is 'Lvalue required', where a is an integer. Would this error disappear had the unary pre increment operator be implemented to return the reference of the integer?Why?

Ans:	
No, because unary operators have right to left associativity and this error can be removed if unary post-decrement operator returns the reference of the integer.

3.What is the range of the variable p in the following case:
	int p:5 ;
How do i get a range of 0 to +7?

Ans:	Range : -16 to +15 
	unsigned int p:3

4.Which are the three kinds of operators whose associativity is from right to left?
Which is the operator with the lowest precedence?

Ans:	unary operators, assigment operators, ternary conditional operators
Comma operator has the lowest precedence




