创建一个新的class
#include <iostream>
#include <stdlib.h>
using namespace std;
class TV //define a new class
{
public:
char name[20];
int type;
void changeVol();
void power();
};
用stack方式来访问object
int main(void)
{
TV tv;
tv.type = 0;
tv.changeVol();
return 0;
}
用heap方式来访问object
结束后需要release memory by using "delete p || delete []p"
int main(void)
{
TV *p = new TV();
p -> type = 0;
p -> changeVol();
delete p;
p = NULL;
return 0;
}