What is the term for a function that is declared inside a class but defined outside of it in C++?
Select an option to see the answer and solution.
What is the process of wrapping data and functions into a single unit called in C++?
Select an option to see the answer and solution.
What is the purpose of the 'this' pointer in C++?
Select an option to see the answer and solution.
What is the purpose of using constructors in C++?
Select an option to see the answer and solution.
What is a constructor in C++?
Select an option to see the answer and solution.
Which keyword is used to create a copy constructor in C++?
Select an option to see the answer and solution.
What is the purpose of a copy constructor in C++?
Select an option to see the answer and solution.
Which access specifier allows members of a class to be accessed only by member functions of the same class and its derived classes in C++?
Select an option to see the answer and solution.
What happens if a class does not explicitly declare any constructors in C++?
Select an option to see the answer and solution.
What is a destructor in C++?
Select an option to see the answer and solution.
Which keyword is used to make a member function constant in C++?
Select an option to see the answer and solution.
What is the difference between a constructor and a normal member function in C++?
Select an option to see the answer and solution.
What is the purpose of the keyword 'explicit' before a constructor in C++?
Select an option to see the answer and solution.
Which keyword is used to prevent inheritance in C++?
Select an option to see the answer and solution.
What is the access specifier that allows members of a class to be accessed from anywhere in the program in C++?
Select an option to see the answer and solution.
What is the difference between a shallow copy and a deep copy in C++?
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
#include <complex>
using namespace std;
int main ()
{
complex<double> mycomplex (20.0, 2.0);
cout << imag(mycomplex) << endl;
return 0;
}
Select an option to see the answer and solution.
How many parameters does a conversion operator may take?
Select an option to see the answer and solution.
What is operator overloading in C++?
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Integer
{
int i;
public:
Integer(int ii) : i(ii) {}
const Integer
operator+(const Integer& rv) const
{
cout << "operator+" << endl;
return Integer(i + rv.i);
}
Integer&
operator+=(const Integer& rv)
{
cout << "operator+=" << endl;
i += rv.i;
return *this;
}
};
int main()
{
int i = 1, j = 2, k = 3;
k += i + j;
Integer ii(1), jj(2), kk(3);
kk += ii + jj;
}
Select an option to see the answer and solution.