Output of C++ Program | Set 7】的更多相关文章

Predict the output of following C++ programs. Question 1 1 #include <iostream> 2 using namespace std; 3 4 template <int N> 5 class A 6 { 7 int arr[N]; 8 public: 9 virtual void fun() 10 { 11 cout << "A::fun()"; 12 } 13 }; 14 15…
Predict the output of following C++ programs. Question 1 1 #include <iostream> 2 using namespace std; 3 4 class A 5 { 6 public: 7 A& operator=(const A&a) 8 { 9 cout << "A's assignment operator called" << endl; 10 return…
Predict the output of following C++ programs. Question 1 1 #include<iostream> 2 using namespace std; 3 4 class Base 5 { 6 public: 7 int fun() 8 { 9 cout << "Base::fun() called"; 10 } 11 int fun(int i) 12 { 13 cout << "Base…
Predict the output of following C++ programs. Question 1 1 #include <iostream> 2 using namespace std; 3 4 class A 5 { 6 public: 7 void print() 8 { 9 cout << "A::print()"; 10 } 11 }; 12 13 class B : private A 14 { 15 public: 16 void p…
Predict the output of following C++ program. Difficulty Level: Rookie Question 1 1 #include <iostream> 2 using namespace std; 3 4 class A 5 { 6 int id; 7 public: 8 A (int i) 9 { 10 id = i; 11 } 12 void print() 13 { 14 cout << id << endl;…
Predict the output of following C++ program. 1 #include<iostream> 2 using namespace std; 3 4 class A 5 { 6 // data members of A 7 public: 8 A () 9 { 10 cout << "\n A's constructor"; /* Initialize data members */ 11 } 12 A (const A &a…
Predict the output of following C++ programs. Question 1 1 #include<iostream> 2 using namespace std; 3 4 class Point 5 { 6 private: 7 int x; 8 int y; 9 public: 10 Point(const Point&p) 11 { 12 x = p.x; 13 y = p.y; 14 } 15 void setX(int i) 16 { 17…
Predict the output of following C++ programs. Question 1 1 template <class S, class T> class Pair 2 { 3 private: 4 S x; 5 T y; 6 /* ... */ 7 }; 8 9 template <class S> class Element 10 { 11 private: 12 S x; 13 /* ... */ 14 }; 15 16 int main ()…
Predict the output of following C++ programs. Question 1 1 class Test1 2 { 3 int y; 4 }; 5 6 class Test2 7 { 8 int x; 9 Test1 t1; 10 public: 11 operator Test1() 12 { 13 return t1; 14 } 15 operator int() 16 { 17 return x; 18 } 19 }; 20 21 void fun ( i…
Predict the output of below C++ programs. Question 1 1 #include<iostream> 2 3 using namespace std; 4 5 class Test 6 { 7 int value; 8 public: 9 Test (int v = 0) 10 { 11 value = v; 12 } 13 int getValue() 14 { 15 return value; 16 } 17 }; 18 19 int main…