Question 10874 – JAVA
November 12, 2023Question 16117 – I/O-Devices
November 12, 2023Question 17043 – JAVA
If a constructor ‘Date’ is declared explicitly and has to be defined outside the class, which of the following is correct?
Correct Answer: A
Question 8 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()
{
}
Date::Date(int dd) {/*…*/}
explicit Date::Date(int dd) {/*…*/}
Such a constructor cannot be defined
Constructor always has to be defined inside the class
Subscribe
Login
0 Comments