[TriLUG] OT: C++ Question

Brian Henning lugmail at cheetah.dynip.com
Mon Jan 30 21:41:02 EST 2006


I'm no expert by any means, but I'm pretty sure you can't overload based
solely on return type.  Yeah, after just testing it, for example,
int mything(int b) {...}
and
float mything(int b) {...}

are ambiguous.  Overloading only works based on function arguments.  So your
vector3d operator+ (vector3d);
and
point3d operator+ (vector3d);
are ambiguous.

Hope this helps...
~Brian



> -----Original Message-----
> From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org]On
> Behalf Of Randy Barlow
> Sent: Monday, January 30, 2006 6:36 PM
> To: Triangle Linux Users Group discussion list
> Subject: [TriLUG] OT: C++ Question
>
>
> Sorry for the OT post, but this problem is driving me nuts!  (If anyone
> knows of a *good* mailing list that this question would be more
> appropriate for, please let me know!)
>
> The problem: I'm getting a compiler error for the following class
> definition:
>
> #pragma once
> #include "vector3d.h"
>
> class point3d {
>     public:
>         double x, y, z;
>         point3d(double, double, double);
>         point3d(void);
>         ~point3d(void);
>         vector3d operator+ (vector3d);
>         point3d operator+ (vector3d);
>         vector3d operator- (point3d);
>         double* operator [] (const int &);
> };
>
> The compiler doesn't like the operator overloading statements,
> complaining about syntax, and that it doesn't know what the vector3d
> identifier is.  However, I've included the vector3d.h file where this
> type (another similar class) is defined.  Am I doing something
> incorrectly here?  Thanks!
>
> --
> Randy Barlow
> Research Assistant
> Department of Electrical and Computer Engineering
> North Carolina State University, Raleigh, NC
> rpbarlow at ncsu.edu
> http://www.electronsweatshop.com
>
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>





More information about the TriLUG mailing list