热门

最新

红包

立Flag

投票

同城

我的

发布
m0_51773783
我最不coo
4 年前
truem0_51773783

新人菜鸟 求大佬指导 谢谢(跪)

#include "stdafx.h"
#include<iostream>
using namespace std;
int p1;
class People{
public:
string Name;
int Sex;
int Age;
int Stature;
peo(string nx, int sx, int ax, int stax);
People *x;
//成员函数,统称为类的方法,display用于显示
void display() {
cout << "姓名:" << this->GetName() << endl;
cout << "性别:" << this->GetSex() << endl;
cout << "年龄:" << this->GetAge() << endl;
cout << "身高:" << this->GetStature() << endl;
};

//声明成员函数
void Set(string Name, int Sex, int Age,int Stature);
string GetName() {
return this->Name; };
int GetSex() {
return this->Sex;};
int GetAge() {
return this->Age;};
int GetStature() {
return this->Stature; };
};
//默认构造函数
People::peo(string nx, int sx, int ax, int stax)
{
this->Name=Name;
this->Sex=Sex;
this->Age=Age;
this->Stature=Stature;
this->Set(nx,sx,ax,stax);
};

int main(int argc, char* argv[])
{
People p1,p2,p3;
p1.Set("张三",0,20,175);
p2.Set("李四",1,21,180);
p3.Set("王五",0,22,185);
p1.display();
p2.display();
p3.display();
return 0;
}

保持热爱共赴山海
CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
一个只与C语言和C++技术相关的宝藏博主:https://cplusplus.blog.csdn.net/
立即登录