 
  お初の方は右側カテゴリーより興味のある記事をご覧ください。まとめシリーズがおすすめです。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
class sample
{
public:
	double data[3];
	sample operator + (const sample& sam)
	{
		sample temp;
		for (int i = 0; i < 3; i++)
			temp.data[i] = data[i] + sam.data[i];
		return temp;
	}
	sample operator * (const double& num)
	{
		sample temp;
		for (int i = 0; i < 3; i++)
			temp.data[i] = data[i] * num;
		return temp;
	}
};
int main()
{
	double num = 1.5;
	sample sam1, sam2, sam3, sam4;
	sam1.data[0] = 100;
	sam1.data[1] = 200;
	sam1.data[2] = 300;
	sam4 = sam3 = sam2 = sam1;
	sam1 = sam2 * num + sam3 * num + sam4 * num;
	for (int i = 0; i < 3; i++)
		printf("[%d] %f\n", i, sam1.data[i]);
	getchar();
    return 0;
}
2007/12/09設置