[C++学习]继承

2021-08-27 10:41:36 浏览数 (1)

[C 学习]继承

代码语言:javascript复制
#include 
#include 
using namespace std;
class Father
{
public:

    void setHeight(int height)
	{
	
		this->height= height;
	}
	int getHeight()
	{
	return height;
	}

	void setWeight(int weight)
	{
		this->weight = weight;
	}

    int getWeight()
	{
     return weight;
	}


	void toString()
	{
		
     cout<<"体重:"<weight<<"身高:"<height<age = age;
	}

	int getAge()
	{
	return age;
	}

	void toString()
	{
		
		cout<<"姓名:t"<name<<"t体重:t"<age<name=name;
	}
	string getName()
	{
	return name;
	}


private:
	int age;
	string name;
};
void main()
{



	Son f ;
     f.setName("张三丰");
     f.setHeight(175);
	 f.setWeight(140);
	 f.setAge(25);


	  f.toString();

}

0 人点赞