Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Online Practice Test
>
CPP
« Previous
Next »
Every class has at least one constructor function, even when none is declared.
Options
- True
- False
CORRECT ANSWER : True
Discussion Board
C++ - Constructors
The above answer is true. Every class has at least one constructor. If you do not mention or write a constructor for a class, C++ generates one constructor for you which is known as Default Constructor. It is not visible in your code, but it is available there.
Constructors are special member function used for initializing the data elements of the object. It is executed when an object of that class is created. Constructors are automatically called when the object of the class is created. It cannot be inherited, but a derived class can call the constructor of the base class. Constructor cannot be static or virtual.
Prajakta Pandit 01-3-2017 12:45 AM
that's not correct.
Class B below has not synthesized default constructor.
class R
{
public:
R(int r){}
};
class B
{
public:
R r;
};
int _tmain(std::string argc, _TCHAR* argv[])
{ return 0;
}
athos liu 01-9-2015 07:53 AM
The answer should be "False"
You can refer to the book "Inside the C++ object model". For exmaple, if a class contains data of only primitive type, no default constructor will be created by the complier.
eddy 12-23-2014 11:53 AM
« Previous
Next »
Write your comments
*
*
Email must be in the form someone@domain.com
*
*
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
Related Content
C test (42)
C (12)
C++ for beginners (10)
C++ (20)
C++ (24)
C++ (18)
C++ (14)
C++ (12)
C++ (15)
C++ (15)
Data structure (20)
Data structure (10)
Data structure (10)
Data structure (10)
PERL (25)
VC++ (11)
Oops (30)
Mainframe (41)
Mainframe (15)
Embedded systems (15)
OOAD (49)
Advertisement
▲