刚学了类写个程序

 

#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;
}

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

原文地址:https://www.cnblogs.com/qiqiBoKe/p/2791599.html