c++ 基础(类)

1. c++ 类的简单使用

#include 
#include
#include

using namespace std;

class Person{
public:
    Person(int h, int a): height(h), age(a){
        // this->height = h;
        // this->age = a;
    }
    int height;
    int age;
};

int main()
{
   Person p(165,20);
   cout << p.height << " " << p.age << endl;
   
   return 0;
}

c++ 基础(类)_第1张图片

你可能感兴趣的:(c++,c++,算法,开发语言)