|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - compile error: no match for function
Hi,
Code as follows:
#include <iostream>
using namespace std;
class Point
{
public:
Point(): x_(0), y_(0) { }
Point(double x, double y): x_(x), y_(y) {}
public:
void X(double x) { x_ = x; }
void Y(double y) { y_ = y; }
double X() { return x_; }
double Y() { return y_; }
private:
double x_;
double y_;
};
// ERROR
// with const gives "no match for function X()"
void print_point(const Point& p)
{
cout << "x: " << p.X() << " y: " << p.Y();
}
int main()
{
Point p1(10, 20);
cout << "x: " << p1.X() << " y: " << p1.Y(); // OK
print_point(p1); // ERROR
return 0;
}
--
Regards,
Hakki Dogusan
Mar 21 2004
Hakki Dogusan wrote: Mar 22 2004
Jan Knepper wrote: Mar 23 2004
Hakki Dogusan wrote:Jan Knepper wrote: Mar 24 2004
|