C++ provides a special ………………… called the constructor, which enables an object to initialize itself when it is created.
Which is the correct form of default constructor for following class?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Constructors are normally used to …………….. and to allocate memory.
What will be the output of following program?
Constructors cannot be inherited, through a derived class can call the ………………. constructor.
Does assignment operator implement automatically with the class?
The constructors that can take arguments are called …………… constructors.
What will be the output of the following code?
#include <iostream>
using namespace std;
//class definition
class Example {
public:
Example()
{
cout << "Constructor called ";
}
};
//main() code
int main()
{
Example Ex1, Ex2;
return 0;
}
In C++, ……………………. creates objects, even through it was not defined in the class.
A constructor is called when an object is being created?
The ………………… constructor can be called with either one argument or no arguments.
A ……………. takes a reference to an object of the same class as itself as an argument.
What will be the output of the following code?
#include <iostream>
using namespace std;
//class definition
class Example {
private:
int a;
int b;
public:
Example(int a, int b)
{
this->a = a;
this->b = b;
}
int get_a()
{
return a;
}
int get_b()
{
return b;
}
};
//main() code
int main()
{
Example Ex(10, 20);
cout << "a = " << Ex.get_a() << ", b = " << Ex.get_b();
return 0;
}
A destructor is used to destroy the objects that have been created by a ………………..
73 videos|7 docs|23 tests
|