92.
What will be the output of the following C++ code?
#include <iostream>
#include <cmath>
using namespace std;
class Complex
{
    private:
    double real;
    double imag;
    public:
    Complex(double r = 0.0, double i = 0.0) : real(r), imag(i)
    {}
    double mag()
    {  
        return getMag();
    }
    operator double ()
    {
        return getMag();
    }
    private:
    double getMag()
    {
        return sqrt(real * real + imag * imag);
    }
};
int main()
{
    Complex com(3.0, 4.0);
    cout << com.mag();
    cout << com;
    return 0
}

96.
How the objects are self-referenced in a member function of that class.

97.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class number
{
    int i;
    public:
    int geti();
    void puti(int j);
};
int number::geti()
{
    return i;
}
void number::puti(int j)
{
    i = j;
}
int main()
{
    number s;
    s.puti(10);
    cout << s.geti( );
    return 0;
}

99.
How many member functions are there in this C++ class excluding constructors and destructors?
class Box
{
	int capacity;
   public:
	void print();
	friend void show();
	bool compare();
	friend bool lost();
};

Read More Section(Classes and Objects in C plus plus)

Each Section contains maximum 100 MCQs question on Classes and Objects in C plus plus. To get more questions visit other sections.