Classes & Objects
- Pick out the correct statement.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Destructors are automatically invoked when a object goes out of scope or when a dynamically allocated object is deleted. Inheritance does not change this behavior. This is the reason a derived destructor cannot invoke its base class destructor.
- Where is the derived class is derived from?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Because derived inherits functions and variables from base.
- What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
public:
Example()
{
cout << "N::N()" << endl;
}
Example( Example const & )
{
cout << "N::N( N const & )" << endl;
}
Example& operator=( Example const & )
{
cout << "N::operator=(N const &)" << endl;
}
};
Example function()
{
Example temp;
return temp;
}
int main()
{
Example p = function();
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
As we are passing the object without any attributes it will return as N::N().
- Which container in c++ will take large objects?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Because the vector is mainly used to store large objects for the game
programming and other operations etc.
- How to store the large objects in c++ if it extends its allocated memory?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
memory heap