指针比较
本文內容來源:《C++必知必會》 條款28
1 #include <stdio.h>
2 class A{
3 public:
4 int a;
5 };
6
7 class B{
8 public:
9 int b;
10 };
11
12 class C: public A, public B{
13 public:
14 int c;
15 };
16 int main(int argc, char **argv)
17 {
18 C *pc = new C();
19 A *pa = pc;
20 B *pb = pc;
21 void *p = (void *)pc;
22 //by now, pc == pa is true, pc == pb is true, pa == pb not valid, compile error
23 // p == pc is true , p == pa is true(compiler dependent), p == pb is false (all of them are raw pointer comparison)
24 return 0;
25 }
轉載于:https://www.cnblogs.com/cmleung/archive/2011/05/25/2057155.html
總結
- 上一篇: chrome扩展之3:一步步跟我学开发一
- 下一篇: Windows 运行... 可执行的命令