#include <fstream>
#include <iostream>
using namespace std;
class Tuzisir {
private:
double height;
int age;
string name;
public:
// 成员函数声明
bool setHeight(double inputHeight);
double getHeight(void);
bool setAge(int inputAge);
int getAge(void);
bool setName(string name);
string getName(void);
};
bool Tuzisir::setHeight(double inputHeight) {
height = inputHeight;
return true;
}
bool Tuzisir::setAge(int inputAge) {
age = inputAge;
return true;
}
bool Tuzisir::setName(string inputName) {
name = inputName;
return true;
}
double Tuzisir::getHeight() {
return height;
}
int Tuzisir::getAge() {
return age;
}
string Tuzisir::getName() {
return name;
}
int main()
{
Tuzisir tuzi1;
string oss;
tuzi1.setAge(23);
tuzi1.setHeight(1.75);
tuzi1.setName("tuzisir");
oss = to_string(tuzi1.getHeight()) + tuzi1.getName() + to_string(tuzi1.getAge());
cout << oss << endl;
}
image.png
网友评论