//客戶主程序
#include<iostream>
#include"vector.h" using namespace std; void main() { vector v1; vector v2(1,1,1); cout<<v1.abs()<<" "<<v2.abs()<<endl; } //vector.h
class vector
{ float x; float y; float z; public: vector(); vector(float,float,float); float abs(); }; //vector.cpp
#include<cmath>
#include"vector.h" vector::vector() { x=0; y=0; z=0; } vector::vector(float a,float b,float c) { x=a;y=b;z=c; } float vector::abs() { return sqrt(x*x+y*y+z*z); } |
|