标题:[求助]关于构造函数
取消只看楼主
27149
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-5-16
 问题点数:0 回复次数:0 
[求助]关于构造函数

// 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)

搜索更多相关主题的帖子: 函数 构造 
2005-06-21 05:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-21275-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.075885 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved