Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- class Island
- {
- private:
- string Name, Location;
- double Area;
- public:
- Island()
- {
- Name = "Noname";
- Location = "Unknown";
- Area = 0.;
- };
- friend istream& operator>>(istream &cin, Island &isl)
- {
- cin >> isl.Name >> isl.Location >> isl.Area;
- return cin;
- };
- friend ostream& operator<<(ostream &cout, Island &isl)
- {
- cout << isl.Name << endl << isl.Location << endl;
- return cout;
- };
- friend Island maxArea(Island *a, int size)
- {
- Island &max = a[0];
- for (int i = 0; i < size; i++)
- if (a[i].Area > max.Area)
- max = a[i];
- return max;
- };
- Island(string N, string L, double A):Name(N), Location(L), Area(A){};
- ~Island(){};
- };
- int main()
- {
- const int N = 29;
- Island *ptr = new Island[N];
- ifstream ifs("Islands.txt");
- Island isl;
- for (int i = 0; i < N; i++)
- {
- ifs >> isl;
- ptr[i] = isl;
- }
- ifs.close();
- cout << maxArea(ptr, N);
- delete [] ptr;
- ptr = NULL;
- system("PAUSE");
- return (0);
- };
Advertisement
Add Comment
Please, Sign In to add comment