类和对象

 

#include <iostream>
//#include <>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


class haha{
    public:
        int age=10;
        int i=10;
        int get(){
            cout<<"这是get函数:"<<endl<<"age:"<<age<<endl<<"i:"<<i<<endl;
            return this->age+i;
        }
        int set(int age,int i){
            this->age=age;
            this->i=i;
        }
        
};

int main(int argc, char** argv) {
    
    haha a;
    int age;
    int i;
    a.set(5,6);
    //cin>>a.age>>a.i;
    cout<<a.get();
    
    
    return 0;
}

 

posted @ 2024-01-27 09:14  郭立恒  阅读(12)  评论(0)    收藏  举报