#include "iostream" #include <string> using namespace std; class mycoach { private: string name; short age = 0; public: void coachgreeting(string _name, int _age) { name = _name; age = _age; cout << "大家好,我是" << name << "今年芳龄" << age << endl; } protected: }; void main() { char r[10] = {0}; cout << "好好学编程,包养陈培昌" << endl; cout << "请翻帅哥的牌子:"; cout << "厉智 陈培昌 程劲"; cin>>r; cout << "这位爷翻了" << r << "的牌子" << endl; mycoach ritz; ritz.coachgreeting("厉智", 31); system("pause"); }
类是一种高级结构体
类是内存固定数据块的别名,类是一个抽象概念,不会为你分配内存,
用数据类型定义变量的时候才会为你分配内存
原文地址:https://www.cnblogs.com/saintdingspage/p/10358567.html
时间: 2024-10-08 02:15:10