c++之初學程序

#include
#include<iostream>
#include<wchar.h>
#include<cstdlib>
#include<iomanip>

using namespace std;
class A
{
private:
    int i;
    int j;
public:
    void point(int a, int b);
    int getx();
    int gety();
    
    
};

void A::point(int a, int b)
    {
        i=a;
        j=b;
    }
int A::getx()
    {
        return i;
    }

int A::gety()
    {
        return j;
    }

int main()
{
    A p1, p2;
    int x,y;
    p1.point (1,2);
    p2.point (3,4);
    x=p1.getx();
    y=p1.gety();
    cout << x <<' '<< y<<endl;
    x=p2.getx();
    y=p2.gety();
    cout << x <<' '<< y<<endl;
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章