运行环境: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;}运行结果:
新闻热点
疑难解答
图片精选