标签:main mem 水平 string static end sizeof class pre
在32位编译环境下进行测试。
#include <iostream>
using namespace std;
class D
{
public:
static void printA()
{
cout<<"printA"<<endl;
}
void printB()
{
cout<<"printB"<<endl;
}
virtual void printC()
{
cout<<"printC"<<endl;
}
};
int main()
{
D *d=NULL;
d->printA();
d->printB();
d->printC();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int i = 5;
cout<<i;
cout<<sizeof(i++);
cout<<i;
return 0;
}
#include <iostream>
using namespace std;
class A
{
};
class B
{
public:
virtual ~B();
};
class C
{
static void fn(){};
};
class D:B
{
~D(){}
};
int main()
{
cout<<sizeof(A)<<endl;
cout<<sizeof(B)<<endl;
cout<<sizeof(C)<<endl;
cout<<sizeof(D)<<endl;
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int a[5];
memset(a,1,sizeof(a));
cout<<a[0];
return 0;
}
标签:main mem 水平 string static end sizeof class pre
原文地址:https://www.cnblogs.com/jhy16193335/p/11588698.html