Which option is false for the following code? [code] class A { private : int sum(int x, int y) { return x+y; } public: A() {

Thê Hy

New member
Which option is false for the following code?
Code:
class A
{
	private : int sum(int x, int y)
	{ 
		return x+y; 
	}
	public: A()
	{  
	}
	A(int x, int y)
	{ 
		cout<<sum(x,y);  
	}
};
A. Constructor can be created with zero argument
B. Constructor prints sum, if two parameters are passed with object creation
C. Constructor will give error if float values are passed
D. Constructor will take 0 as default value of parameters if not passed
 
Answer: d
Explanation: Constructor is not having any default arguments hence no default value will be given to any parameters. Only integer values must be passed to the constructor if we need the sum as output, otherwise if float values are passed, type mismatch will be shown as error.
 

Tìm kiếm

Back
Top