...
OOPS
November 12, 2023
Question 16117 – I/O-Devices
November 12, 2023
OOPS
November 12, 2023
Question 16117 – I/O-Devices
November 12, 2023

NTA 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?
A
Date::Date(int dd) {/*…*/}
B
explicit Date::Date(int dd) {/*…*/}
C
Such a constructor cannot be defined
D
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();
};

// 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();
};

// Defining a Constructor Outside of the Class by using :: operator
class_name::class_name()
{
}

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!