Simple2012

Untitled

Oct 20th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include "circle.h"
  2. #include "shape.h"
  3. #include "cylinder"
  4. #include "prallelpiped"
  5. #include "rectangle"
  6. #include "roundedRectangle"
  7. #include <vector>
  8.  
  9. void GetData(std::vector<shape *> v, size_t size){
  10.     for(int i = 0; i < size ; i++)
  11.     {
  12.         if ( v[i] == 0 )
  13.             return;
  14.         (v[i])->GetArea();
  15.     }
  16. }
  17.  
  18. /*  polymorphic area calculation of the total area of all shapes in the array,
  19.     as well as displaying information about their colours.
  20.     Needless to say that the function GetData must not be changed in
  21.     case of adding some new shape to the array or removing an old one. */
  22.  
  23. int main(int argc, char const *argv[]){
  24.     std::vector<shape *> derivedClassHolder(1);
  25.     derivedClassHolder[0] = new circle;
  26.     derivedClassHolder[1] = new cylinder;
  27.     derivedClassHolder[2] = new prallelpiped;
  28.     derivedClassHolder[3] = new rectangle;
  29.     derivedClassHolder[4] = new roundedRectangle;
  30.  
  31.  
  32.     GetData(derivedClassHolder, derivedClassHolder.size());
  33.  
  34.     /*for(int i = 0; i < (int)derivedClassHolder.size() ; i++)
  35.     {
  36.         ((circle*)derivedClassHolder[i])->SetRadius(14);
  37.     }*/
  38. }
Advertisement
Add Comment
Please, Sign In to add comment