mardi 28 mars 2017

c++,object,undefined reference to [duplicate]

// as a header file

#ifndef GPSCOORD_H
#define GPSCOORD_H
#include <cstdlib>
#include <iostream>
#include <cstring>

using namespace std;

class GPSCoord{
public:
double longtitude;
double lattitude;

 GPSCoord ();
GPSCoord(double m_lattitude,double m_longtitude){

    longtitude=m_longtitude;
    lattitude=m_lattitude;
}
void print();
void setLattitude(double m_lattitude){
    this->lattitude=m_lattitude;
}
void setLongtitude(double m_longtitude){
this->longtitude=m_longtitude;
}

double getlong(){
    return this->longtitude;
}
double getlat(){
    return this ->lattitude;
}
};
#endif

as cpp

#include <iostream>
#include "gpscoord.h"
#include "gpspath.h"
using namespace std;
double a,b;

void GPSPath::add_point(){

 GPSCoord m;//problem is in here(undefined reference to

cout<<"write your new lattitude"<< endl;
cin>>b;
m.setLattitude(b);
cout<<"write your new longtitude"<<endl;
cin>>a;
m.setLongtitude(a);

m_points.push_back(m);
m.getlat();


 }

and also there is a header named gpspath

#ifndef GPSPATH_H
#define GPSPATH_H

   #include <iostream>
   #include <vector>
   #include "gpscoord.h"
   using namespace std;


class GPSPath{
private:
   vector<GPSCoord> m_points;
public:
    vector<GPSCoord> & get_m_points(){ return m_points;}
   void add_point();
   void total_distance();
   void print() ;


size_t size()const{return m_points.size();}

       };
    #endif

When ı press the start it says it say undefined reference to GPSCoord ı cant understand whay it does this kind of error.I am new at c++ ,your help would be very useful.Thankyou. full of the problem : error: undefined reference to `GPSCoord::GPSCoord()'

Aucun commentaire:

Enregistrer un commentaire