Classes & Objects
- 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
- Which special character is used to mark the end of class?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
; special character is used to mark the end of class.
- What is the output of this program?
#include
using namespace std;
class num
{
int N;
public:
int getN();
void putN(int M);
};
int num::getN()
{
return N;
}
void num::putN(int M)
{
N = M;
}
int main()
{
num obj;
obj.putN(15);
cout << obj.getN( );
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
We are getting the number and copying it to M and printing it.
- What is the output of this program?
#include <iostream>
using namespace std;
class Base
{
protected:
int K;
public:
Base(int num1)
{
K = num1;
}
~Base()
{
}
};
class Derived: public Base
{
int L;
public:
Derived(int num1, int num2): Base(num2)
{
L = num1;
}
~Derived()
{
}
void show()
{
cout << K << " " << L << endl;
}
};
int main()
{
Derived object(5, 6);
object.show();
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We are passing the values and assigning it to K and L and we are printing it.
- 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.