标签:c++
#include <iostream> #include <stdlib.h> using namespace std; class xiaok{ public: int k; int a; void han(){cout<<k<<a<<endl;} }; int main(int argc, char const *argv[]) { xiaok *p=(xiaok*)malloc(sizeof(xiaok)); new(p) xiaok(); p->a=10; p->k=20; p->han(); return 0; } //////////------------------------- #include <iostream> #include <stdlib.h> using namespace std; class xiaok{ public: int k; int a; void han(){cout<<k<<a<<endl;} }; int main(int argc, char const *argv[]) { void *p=malloc(sizeof(xiaok)); new(p) xiaok(); xiaok *vp=(xiaok*)p; vp->a=10; vp->k=20; vp->han(); return 0; }
标签:c++
原文地址:http://blog.csdn.net/h1023417614/article/details/46350727