It looks like Coord(a)
doesn't work , and the values for lon
and lat
are 00.0000
and 00.0000
, those from the default constructor . What should I do?
Ia there a problem with the syntax ? Isn't it in >> Coord(a)
to read lon
and lat
from base class?
//base class
class Coord {
private:
double lon;
double lat;
Coord() { lon = 00.000000000000000; lat = 00.000000000000000; }
//.....
//.....
//.....
friend istream& operator>>(istream& in, Coord& temp)
{
cout << "Longitude is : "; in >> temp.lon;
cout << "Latitude is : "; in >> temp.lat;
return in;
}
};
//derived class
class Location : public Coord {
private:
char model[6];
double time;
int speed;
//.....
//.....
//.....
friend istream& operator>>(istream& in, Location& a)
{
cout << "Model is : "; in >> a.model;
cout << "Time is : "; in >> a.time;
cout << "Speed is : "; in >> a.speed;
cout << "Coordinates : " << endl; in >> Coord(a);
return in;
}
};
void main()
{
Location loc;
cin>>loc; cout<<loc;
}