Vidyalelo
C++ Programming · Q122

Functions and Procedures in C++

Programming · C++ Programming · question 122

Q122

What will be the output of the following C++ code? #include using namespace std; class Test protected: int x; public: Test (int i):x(i) void fun() const cout << "fun() const " << endl; void fun() cout << "fun() " << endl; ; int main() Test t1 (10); const Test t2 (20); t1.fun(); t2.fun(); return 0;

A.
fun()
fun() const
Answer
B.
fun() const
fun()
C.
fun()
fun()
D.
fun() const
fun() const

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board