/*
*Copyright (c)2015,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:score.cpp
*作 者:惠睿
*完成日期:2015年3月28日
*版 本 号:v1.0
*
*问题描述:理解构造函数和构析函数。
*程序输入:无输入。
*程序输出:输出二维数组。
*/
#include <iostream>
using namespace std;
class toy
{
public:
toy(int q, int p)
{
quan = q;
price = p;
}
int get_quan()
{
return quan;
}
int get_price()
{
return price;
}
private:
int quan, price;
};
int main()
{
toy op[3][2]=
{
toy(10,20),toy(30,48),
toy(50,68),toy(70,80),
toy(90,16),toy(11,120)
};
int i;
for (i=0; i<3; i++)
{
cout<<op[i][0].get_quan()<<",";
cout<<op[i][0].get_price()<<"\n";
cout<<op[i][1].get_quan()<<",";
cout<<op[i][1].get_price()<<"\n";
}
cout<<"\n";
return 0;
}
预计 实际运行结果: