Yurttas/PL/OOL/Cplusplus/F/08/01/01/00/fruits 24.cpp

 1/*
 2   Copyright(C) 1998
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : January 1, 1998.
11   authorĀ : Salih Yurttas.
12
13   fruits_24.cpp
14*/
15
16
17#include <iostream>
18#include <vector>
19
20using namespace std;
21
22#include "Apple.h"
23#include "Orange.h"
24
25int main(int argc, char* argv[]) {
26
27  vector<Fruit *> fp_a;
28  
29  fp_a.push_back(new Apple);
30
31  fp_a[0]->set_price(2);
32  cout << fp_a[0]->identify() << endl;
33  fp_a[0]->print_price();
34  cout << endl;
35
36  fp_a.push_back(new Apple);
37
38  fp_a[1]->set_price(4);
39  cout << fp_a[1]->identify() << endl;
40  fp_a[1]->print_price();
41  cout << endl;
42
43  vector<Fruit *> fp_o;
44  
45  fp_o.push_back(new Orange);
46
47  fp_o[0]->set_price(1);
48  cout << fp_o[0]->identify() << endl;
49  fp_o[0]->print_price();
50  cout << endl;
51
52  fp_o.push_back(new Orange);
53
54  fp_o[1]->set_price(2);
55  cout << fp_o[1]->identify() << endl;
56  fp_o[1]->print_price();
57  cout << endl;
58
59}