Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sol-final-ex1.cpp : Defines the entry point for the console application.
- #include "stdafx.h"
- #include "iostream"
- using namespace std;
- class omar {
- private:
- int area, population;
- public:
- omar() {
- }
- omar(int a, int p) {
- area = a;
- population = p;
- }
- void display(){
- cout << "area : " << area << "\npopulation : " << population << endl;
- }
- int get_area() {
- return area;
- }
- int get_pop() {
- return population;
- }
- };
- omar addcity(omar city1, omar city2) {
- int area,population;
- area = city1.get_area();
- population = city2.get_pop();
- omar temp(area, population);
- return temp;
- }
- int main()
- {
- omar city1(200, 1000), city2(400, 3000),city3;
- city1.display();
- cout << "\n=======\n";
- city2.display();
- // city3 = area from city1 and population from city2
- city3 = addcity(city1, city2);
- city3.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment