📄 main.cpp
字号:
#include <iostream>
#include <stdlib.h>
using namespace std;
class A
{
public:
A(){ n=5; }
void g()
{
cout << "ggg" << endl;
cout <<"The address of n is:" <<(unsigned long)&n <<endl;
}
private:
int n;
};
class B
{
public:
B(){ m=5; }
void f()
{
cout << "fff" << endl;
cout <<"The address of m is:" <<(unsigned long) &m <<endl;
}
private:
int m;
};
class C : public A, public B
{
public:
C(){ u=5; }
void show()
{
A::g();
B::f();
cout <<"The address of u is:" << (unsigned long)&u <<endl;
cout << "The size of this pointer is:" << sizeof(this) <<endl;
cout << "The value of this pointer is:" << (unsigned long)this <<endl;
}
private:
int u;
};
int main(int argc, char *argv[])
{
C c;
c.show();
cout <<"/////////////////////////////////////////////" <<endl;
C c2;
c2.show();
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -