刚学了类写个程序

 

#include "iostream.h"
#include "string"
class car
{
      
public:
 char color[5];
 void honk();
};
void car::honk()
{
 cout<<"beep!!"<<endl;
}
void main()
{car benchi,*p;
p=new car;
p->honk();
 benchi.honk();
 strcpy(benchi.color,"blue");
  cout<<benchi.color<<endl;
}

刚学的类,其实面向过程也差不多,就是定义几个函数,然后再调用

posted @ 2011-11-15 17:08  奇奇博客  阅读(99)  评论(0编辑  收藏  举报