上一页 1 2 3 4 5 6 7 8 ··· 11 下一页
摘要: 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) 编辑
摘要: A nested class is a class which is declared in another enclosing class. A nested class is a member and as such has the same access rights as any other member. The members of an enclosing class have no special access to members of a nested class; the usual access rules shall be obeyed. For examp... 阅读全文
posted @ 2013-11-27 14:41 虔诚的学习者 阅读(378) 评论(0) 推荐(1) 编辑
摘要: A class declared inside a function becomes local to that function and is called Local Class in C++. For example, in the following program, Test is a local class in fun(). 1 #include 2 using namespace std; 3 4 void fun() 5 { 6 class Test // local to fun 7 { 8 /* members of Te... 阅读全文
posted @ 2013-11-27 14:34 虔诚的学习者 阅读(522) 评论(0) 推荐(0) 编辑
摘要: Ever wondered how can you design a class in C++ which can’t be inherited. Java and C# programming languages have this feature built-in. You can use final keyword in java, sealed in C# to make a class non-extendable. Below is a mechanism using which we can achieve the same behavior in C++. It make... 阅读全文
posted @ 2013-11-27 14:21 虔诚的学习者 阅读(230) 评论(0) 推荐(0) 编辑
摘要: C allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not; this idiom appears often in C code using malloc memory allocation. For example, the following is valid in C but not C++:void* ptr;int *i = ptr; /* Implicit conversion from void* to int* */ or similar... 阅读全文
posted @ 2013-11-27 12:31 虔诚的学习者 阅读(209) 评论(0) 推荐(0) 编辑
摘要: In C, it might not be possible to have function names on left side of an expression, but it’s possible in C++. 1 #include 2 using namespace std; 3 4 /* such a function will not be safe if x is non static variable of it */ 5 int &fun() 6 { 7 static int x; 8 return x; 9 } 10 11 int main... 阅读全文
posted @ 2013-11-27 12:24 虔诚的学习者 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 11 下一页