当前位置: 代码迷 >> 综合 >> 第四周上机程序报告二
  详细解决方案

第四周上机程序报告二

热度:69   发布时间:2024-01-22 04:44:27.0

 

 

/* 
02.* 程序的版权和版本声明部分 
03.* Copyright (c)2012, 烟台大学计算机学院学生 
04.* All rightsreserved. 
05.* 文件名称: object.cpp 
06.* 作者:李全港
07.* 完成日期: 2013年3  月  22日 
08.* 版本号: v1.0 
09.* 输入描述:无 
10.* 问题描述: 
11.* 程序输出:
12.*/  #include<iostream>
using namespace std;
class Test
{ private:
int x,y;
public:
void setX(int a) {x=a;}
void setY(int b) {y=b;}
void getXY(int &px, int &py) //引用
{px=x;py=y;} //提取x,y值
};
void main(void)
{	Test p1,p2;
p1.setX(3);p1.setY(5);
int a,b;
p1.getXY(a, b); //将 a=x, b=y
cout<<a<<'\t'<<b<<endl; 
}
class Test
{private:
int x,y;
public:
void setX(int a) {x=a;}
void setY(int b) {y=b;}
int getX(void) {return x;} //返回x值
int getY(void) {return y;} //返回y值
};
void main(void)
{	Test p1,p2;
p1.setX(3);p1.setY(5);
int a,b;
a=p1.getX( ); b=p1.getY(); 
cout<<a<<'\t'<<b<<endl; 
}
class Test
{private:
int x,y;
public:
void setX(int a) {x=a;}
void setY(int b) {y=b;}
void getXY(int *px, int *py) 
{*px=x;*py=y;}//提取x,y值
};
void  main(void)
{	Test p1,p2;
p1.setX(3);p1.setY(5);
int a,b;
p1.getXY(&a,&b);  //将 a=x, b=y
cout<<a<<'\t'<<b<<endl;  
}


 

 

 

 

  相关解决方案