11. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class numbers
{
private:
int m_nValues[10];
public:
int& operator[] (const int nValue);
};
int& numbers::operator[](const int nValue)
{
return m_nValues[nValue];
}
int main()
{
numbers N;
N[5] = 4;
cout << N[5];
return 0;
}
#include <iostream>
using namespace std;
class numbers
{
private:
int m_nValues[10];
public:
int& operator[] (const int nValue);
};
int& numbers::operator[](const int nValue)
{
return m_nValues[nValue];
}
int main()
{
numbers N;
N[5] = 4;
cout << N[5];
return 0;
}
12. Pick out the correct statement.
13. What is the return type of the conversion operator?
14. Which functions of a class are called inline functions?
15. What will happen when the function call operator is overloaded?
16. How many real types are there in complex numbers?
17. Which of these following members are not accessed by using direct member access operator?
18. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
typedef int num;
typedef char let;
let w = "steve";
num a = 10, b = 15;
num c = a + w;
cout << c;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
typedef int num;
typedef char let;
let w = "steve";
num a = 10, b = 15;
num c = a + w;
cout << c;
return 0;
}
19. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
char str[10];
cin>>str;
cout<<str;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
char str[10];
cin>>str;
cout<<str;
return 0;
}
20. When struct is used instead of the keyword class means, what will happen in the program?
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.