C/C++の宿題を片付けます 40代目
■ このスレッドは過去ログ倉庫に格納されています
0280デフォルトの名無しさん
05/02/11 01:47:15#include <iostream>
#include <cmath>
class VECTOR2
{
double x, y;
public:
VECTOR2(double xs, double ys) : x(xs), y(ys) {}
void print() const{std::cout << '(' << x << ',' << y << ')';}
double abs() const{return std::sqrt(x * x + y * y);}
friend const VECTOR2 operator+(const VECTOR2& lhs, const VECTOR2& rhs)
{
return VECTOR2(lhs.x + rhs.x, lhs.y + rhs.y);
}
};
■ このスレッドは過去ログ倉庫に格納されています