OOPS
November 12, 2023Question 16117 – I/O-Devices
November 12, 2023NTA UGC NET DEC-2022 Paper-2
Question 11 |
If a constructor ‘Date’ is declared explicitly and has to be defined outside the class, which of the following is correct?
Date::Date(int dd) {/*…*/} | |
explicit Date::Date(int dd) {/*…*/} | |
Such a constructor cannot be defined | |
Constructor always has to be defined inside the class |
Question 11 Explanation:
Defining a Constructor Outside of the Class :Although the constructor can be defined outside of the class, it must be declared inside class. Use the scope resolution operator while defining a constructor outside of the class.
class class_name {
public:
class_name();
};
class class_name {
public:
class_name();
};
// Defining a Constructor Outside of the Class by using :: operator
class_name::class_name()
{
}
Correct Answer: A
Question 11 Explanation:
Defining a Constructor Outside of the Class :Although the constructor can be defined outside of the class, it must be declared inside class. Use the scope resolution operator while defining a constructor outside of the class.
class class_name {
public:
class_name();
};
class class_name {
public:
class_name();
};
// Defining a Constructor Outside of the Class by using :: operator
class_name::class_name()
{
}
Subscribe
Login
0 Comments