運行環境:macOS shell 代碼:
#include <iostream>#include <iomanip>#include <string>using namespace std;class point{PRivate: double fx, fy;public: point(); point(double x, double y); void showpoint();};point::point(){ fx = 0.0; fy = 0.0;}point::point(double x, double y = 5.5){ fx = x; fy = y;}void point::showpoint(){ cout<<fx<<" "<<fy<<endl;}int main (){ point p1; cout<<"the fx and fy of p1 : "; p1.showpoint(); point p2(10); cout<<"the fx and fy of p2 : "; p2.showpoint(); point p3(1.1,2.0); cout<<"the fx and fy of p3 : "; p3.showpoint(); return 0;}運行結果:
新聞熱點
疑難解答
圖片精選