// 11.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include "iostream.h" class point { public: point(double,double); private: double x,y; };
point::point(double tx,double ty) { x=tx; y=ty; cout<<"constructor is called:("<<x<<","<<y<<")"<<endl; }
int main(int argc, char* argv[]) { point p1(0.5.0.6); point p2(0.5,0.5663); return 0; } 这样做应该没错啊。 --------------------Configuration: 11 - Win32 Debug-------------------- Compiling... 11.cpp G:\c++工作区\11\11.cpp(23) : error C2143: syntax error : missing ')' before 'constant' G:\c++工作区\11\11.cpp(23) : error C2664: '__thiscall point::point(const class point &)' : cannot convert parameter 1 from 'const double' to 'const class point &' Reason: cannot convert from 'const double' to 'const class point' No constructor could take the source type, or constructor overload resolution was ambiguous G:\c++工作区\11\11.cpp(23) : error C2059: syntax error : ')' Error executing cl.exe.
11.obj - 3 error(s), 0 warning(s)