// image.cpp -- Implementation file for the satellite image class. // Used in CS11 lab 10, fall 1999. #include "image.h" #include #include #include #include // default constructor image::image() { image_num = 0; strcpy (satellite, ""); latitude = 0.0; lat_direction = 'N'; longitude = 0.0; lon_direction = 'N'; altitude = 0.0; } // initial-value constructor image::image(char s[]) { char lat_dir_str[5], lon_dir_str[5]; // Use strtok() to parse the string, and then use atof() // to convert from string to floating-point number. image_num = atoi (strtok (s, " ")); strcpy (satellite, strtok (0, " ")); latitude = atof (strtok (0, " ")); strcpy (lat_dir_str, strtok (0, " ")); lat_direction = lat_dir_str[0]; longitude = atof (strtok (0, " ")); strcpy (lon_dir_str, strtok (0, " ")); lon_direction = lon_dir_str[0]; altitude = atof (strtok (0, " ")); } // Assignment operator simply copies all the data attributes. image& image::operator = (const image &i) { image_num = i.image_num; strcpy (satellite, i.satellite); latitude = i.latitude; lat_direction = i.lat_direction; longitude = i.longitude; lon_direction = i.lon_direction; altitude = i.altitude; return *this; } // Implementation of the << (output) operator. // You will need to modify this so that it looks more // complete and easy to read. ostream& operator << (ostream &os, image &i) { os << i.image_num; return os; }