what this error message says?

This is a discussion on what this error message says? within the C++ Programming forums, part of the General Programming Boards category; Hi all,im trying to use references on my 2D point class.And after having tens of error,i could reduce it to ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    18

    what this error message says?

    Hi all,im trying to use references on my 2D point class.And after having tens of error,i could reduce it to one.But i cant get rid of it.Can anyone tell me why i have this error massage ?

    Code:

    Code:
    #ifndef TPOINT2D_H_
    #define TPOINT2D_H_
    
    //#include <cmath>
    #include <math.h>
    #define PI 3.14159265358979
    
    
    using namespace std;
    
    class TPoint2D
    {
    	public:
    
    
            explicit  TPoint2D( const double  &coord1=0.0 ,const double  &coord2=0.0 );
            double Distance(TPoint2D &pointA, TPoint2D &pointB);
            double  TPoint2D::Ro();
            double TPoint2D::Phi();
            double Ro(TPoint2D pointA);
            double Phi(TPoint2D pointA);
    
            TPoint2D::TPoint2D(const double &coord1 , const double &coord2 );
            const double & TPoint2D::Coord1();
            const double & TPoint2D::Coord2();
    
    
     private:
    
          double coord1_,coord2_;
    
    
    };
    
    TPoint2D::TPoint2D(const double &coord1 , const double & coord2):coord1_(coord1),coord2_(coord2){};
    
    inline const double & TPoint2D::Coord1()
    {
    	return coord1_;
    }
    
    
    inline const double & TPoint2D::Coord2()
    {
    	return coord2_;
    }
    
    
    double  TPoint2D::Ro()
    {       return sqrt (Coord1()*Coord1()+
                         Coord2()*Coord2());
    }
    
    double  TPoint2D::Phi()
    {
            return atan2 (Coord1(),Coord2()) ;
    }
    
    double Distance(TPoint2D pointA, TPoint2D pointB)
    {
            return sqrt((pow((pointA.Coord1()-pointB.Coord1()),2)+
                       pow((pointA.Coord2()-pointB.Coord2()),2)));
    }
    
    double Ro(TPoint2D pointA)
    {
            return pointA.Ro();
    }
    
    double Phi(TPoint2D pointA)
    {
            return pointA.Phi();
    }
    
    #endif /*END OF TPOINT2D_H_*/
    Error Message:

    Code:
    TPoint2D.h:23: error: `TPoint2D::TPoint2D(const double&, const double&)' and `TPoint2D::TPoint2D(const double&, const double&)' cannot be overloaded

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    You have:

    Code:
    TPoint2D::TPoint2D(const double &coord1 , const double &coord2 );
    explicit  TPoint2D( const double  &coord1=0.0 ,const double  &coord2=0.0 );

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Thanks Tonto i had it worked.I had my VEctor class updated the same way but this time it gives me Unterminated comment error.I have tried to write to code from the beginning many times but had the same error.I dont understand what is the reason.
    Code:

    Code:
    #ifndef TVECTOR_H_
    #define TVECTOR_H_
    
    //#include <cmath>
    
    
    #include <math.h>
    #include "TPoint2D.h"
    #define PI 3.14159265358979
    
    using namespace std;
    
    class TVector
    {
    public:
    
    
    explicit TVector (TPoint2D  point=0);
    const  TPoint2D &TVector::Point();
    double TVector::Length();
    double TVector::Phi();
    double Length(TVector  Vector);
    double Phi(TVector  Vector);
    
    private:
    TPoint2D point_;
    };
    
    
    TVector::TVector(TPoint2D point):point_(point){};
    
    
    inline const TPoint2D & TVector::Point()
    {
        return point_;
    }
    
    
    double TVector::Length()
    {
        return Ro(Point());
    }
    
    double Length(TVector Vector)
    
    {
        return Vector.Length();
    }
    
    
    #endif /*END OF TVECTOR_H_
    Error message:

    Code:
    TVector.h:60:8: unterminated comment

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    >>#endif /*END OF TVECTOR_H_*/
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Thanks a lot JaWiB,i dont know how to stop this stupid mistakes i spent so long time writing this over and over.you saved my hours.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21