Which among the following is correct for the code given below? [code] class student { private: student() { } public : student(

Giang Phạm

New member
Which among the following is correct for the code given below?
Code:
class student
{  
	private: student()
	{  
	}
	public : student( int x) 
	{ 
		marks =x; 
	}
};
A. The object can never be created
B. The object can be created without parameters
C. Only the object with only 1 parameter can be created
D. Only the object with some parameters can be created
 
Answer: c
Explanation: For creating object without parameters, the default constructor must be defined in public access. But here, only parameterized constructor is public, hence the objects being created with only one parameter will only be allowed.
 

Tìm kiếm

Back
Top