摘要: Predict the output of following C++ programs.Question 1 1 #include 2 using namespace std; 3 4 template 5 class A 6 { 7 int arr[N]; 8 public: 9 virtual void fun() 10 { 11 cout 16 {17 public:18 void fun() 19 { 20 cout *a = new C;31 a->fun();32 return... 阅读全文
posted @ 2013-11-27 16:54 虔诚的学习者 阅读(231) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 2 using namespace std; 3 4 class A 5 { 6 public: 7 A& operator=(const A&a) 8 { 9 cout 2 #include 3 4 using namespace std; 5 6 class Test 7 { 8 public: 9 void* operator new(size_t size);10 void operator... 阅读全文
posted @ 2013-11-27 16:44 虔诚的学习者 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 2 using namespace std; 3 4 class Base 5 { 6 public: 7 int fun() 8 { 9 cout 2 using namespace std; 3 class Base 4 { 5 protected: 6 int x; 7 public: 8 Base (int i) 9 { 10 x = i;11 }1... 阅读全文
posted @ 2013-11-27 16:35 虔诚的学习者 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 2 using namespace std; 3 4 class A 5 { 6 public: 7 void print() 8 { 9 cout 2 using namespace std; 3 4 class base 5 { 6 public: 7 virtual void show() 8 { 9 coutshow();36 cout getX();37 ... 阅读全文
posted @ 2013-11-27 16:29 虔诚的学习者 阅读(247) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ program. Difficulty Level: RookieQuestion 1 1 #include 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 2 using namespace std; 3 4 class A 5 { 6 ... 阅读全文
posted @ 2013-11-27 16:23 虔诚的学习者 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ program. 1 #include 2 using namespace std; 3 4 class A 5 { 6 // data members of A 7 public: 8 A () 9 { 10 cout a = a; 37 cout a = a;” in B’s constructor. The fourth line is printed by cout statement in B’s constructor. I... 阅读全文
posted @ 2013-11-27 16:14 虔诚的学习者 阅读(239) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 2 using namespace std; 3 4 int fun(int a, int b = 1, int c =2) 5 { 6 return (a + b + c); 7 } 8 9 int main()10 {11 cout 2 using namespace std; 3 4 /* local variable is same as a member's name */ 5 class Test 6 { 7 pri... 阅读全文
posted @ 2013-11-27 16:09 虔诚的学习者 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 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 x = i;18 ... 阅读全文
posted @ 2013-11-27 16:03 虔诚的学习者 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 2 #include 3 using namespace std; 4 5 class String 6 { 7 char *p; 8 int len; 9 public:10 String(const char *a);11 };12 13 String::String(const char *a)14 {15 int length = strlen(a);16 p = new char[length +1];17... 阅读全文
posted @ 2013-11-27 15:56 虔诚的学习者 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 template class Pair 2 { 3 private: 4 S x; 5 T y; 6 /* ... */ 7 }; 8 9 template class Element10 {11 private:12 S x;13 /* ... */14 };15 16 int main ()17 {18 Pair , Element> p;19 return 0;20 } Output: Compiler ... 阅读全文
posted @ 2013-11-27 15:49 虔诚的学习者 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Predict the output of following C++ programs.Question 1 1 #include 2 using namespace std; 3 4 class Test1 5 { 6 int x; 7 public: 8 void show() 9 { 10 }11 };12 13 class Test214 {15 int x;16 public:17 virtual void show() 18 { 19 }20 };21 22 int main(void)23 {24 ... 阅读全文
posted @ 2013-11-27 15:42 虔诚的学习者 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 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 ( ... 阅读全文
posted @ 2013-11-27 15:36 虔诚的学习者 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Predict the output of below C++ programs.Question 1 1 #include 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() 20 {21 cons... 阅读全文
posted @ 2013-11-27 15:28 虔诚的学习者 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Difficulty Level: Rookie Predict the output of below C++ programs.Question 1 1 #include 2 using namespace std; 3 4 class Test 5 { 6 int value; 7 public: 8 Test(int v); 9 };10 11 Test::Test(int v) 12 {13 value = v;14 }15 16 int main() 17 {18 Test t[100];19 return 0;20 } Outp... 阅读全文
posted @ 2013-11-27 15:23 虔诚的学习者 阅读(200) 评论(0) 推荐(0) 编辑
摘要: Difficulty Level: Rookie Predict the output of below C++ programs. Question 1 1 #include 2 using namespace std; 3 4 int x = 10; 5 void fun() 6 { 7 int x = 2; 8 { 9 int x = 1;10 cout 2 using namespace std; 3 4 class Point 5 { 6 private: 7 int x; 8 int y; 9 publ... 阅读全文
posted @ 2013-11-27 15:17 虔诚的学习者 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Predict the output of below C++ programs. Question 1 1 #include 2 using namespace std; 3 4 class P 5 { 6 public: 7 void print() 8 { 9 cout 2 #include 3 4 using namespace std; 5 6 class Base 7 { 8 public: 9 Base()10 {11 fun(); //note: fun() is virtual12 }1... 阅读全文
posted @ 2013-11-27 15:06 虔诚的学习者 阅读(230) 评论(0) 推荐(0) 编辑
摘要: Predict the output of below C++ programs. Question 1 1 #include 2 using namespace std; 3 4 class A 5 { 6 public: 7 A(int ii = 0) : i(ii) 8 { 9 }10 void show() 11 { 12 cout 2 using namespace std; 3 4 class base 5 { 6 int arr[10]; 7 }; 8 9 class b1: publ... 阅读全文
posted @ 2013-11-27 15:01 虔诚的学习者 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Predict the output of below C++ programs. Question 1 1 // Assume that integers take 4 bytes. 2 #include 3 4 using namespace std; 5 6 class Test 7 { 8 static int i; 9 int j;10 };11 12 int Test::i;13 14 int main()15 {16 cout 2 using namespace std; 3 4 class Base1 5 { 6 public:... 阅读全文
posted @ 2013-11-27 14:55 虔诚的学习者 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Every literal (constant) in C/C++ will have a type information associated with it. In both C and C++, numeric literals (e.g. 10) will have int as their type. It means sizeof(10) and sizeof(int) will return same value. However, character literals (e.g. ‘V’) will have different types, sizeof(‘V’... 阅读全文
posted @ 2013-11-27 14:50 虔诚的学习者 阅读(365) 评论(0) 推荐(0) 编辑
摘要: In C++, namespaces can be nested, and resolution of namespace variables is hierarchical. For example, in the following code, namespace inner is created inside namespace outer, which is inside the global namespace. In the line “int z = x”, x refers to outer::x. If x would not have been in outer... 阅读全文
posted @ 2013-11-27 14:44 虔诚的学习者 阅读(268) 评论(0) 推荐(0) 编辑