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

From ZCubes Wiki
Revision as of 00:26, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="cpp" line start="1" enclose="div">/* Copyright(C) 1998 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. Perm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 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_34.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;
28  vector< vector<Fruit *> > f_p;
29  
30  fp.push_back(new Apple);
31
32  fp[0]->set_price(2);
33  cout << fp[0]->identify() << endl;
34  fp[0]->print_price();
35  cout << endl;
36
37  fp.push_back(new Apple);
38
39  fp[1]->set_price(4);
40  cout << fp[1]->identify() << endl;
41  fp[1]->print_price();
42  cout << endl;
43
44  f_p.push_back(fp);
45
46  fp.push_back(new Orange);
47
48  fp[2]->set_price(1);
49  cout << fp[2]->identify() << endl;
50  fp[2]->print_price();
51  cout << endl;
52
53  fp.push_back(new Orange);
54
55  fp[3]->set_price(2);
56  cout << fp[3]->identify() << endl;
57  fp[3]->print_price();
58  cout << endl;
59
60  f_p.push_back(fp);
61
62  cout << f_p[0][0]->identify() << endl;
63  f_p[0][0]->print_price();
64  cout << endl;
65
66}