Ozellikle ATLAS yazilimiyla ugrasacaksaniz ve daha onceden nesneye yonelimli hic kod yazmadiysaniz, bunun pratigini yaparacak baslamak zorunlu. class, inheritence, method, instantiation gibi terimlerin ne anlama geldigini anlamis olmalisiniz. Bu baglamda daha herhangi bir konuyu tartismaya bile baslamadan su alistirmayi yapin:

Exercise 1:
  • Create a class named Shape. This class should have virtual methods Area() and Circumference().
  • Create a class named Rectangle that inherits from Shape. It should have a constructor taking in the lengths of its two sides. You should be able to create instances of this class and have it report proper values for area and circumference, ie. Rectangle ABCD(3,4); cout << ABCD.Area() << endl; must return 12.
  • Create a class named Square that inherits from Rectangle. Same exercise as with Rectangle.
Exercise 2:
  • Create a class named 2DPoint. It should have a constructor that takes the (x,y) coordinates. It should have another constructor that takes (rho,phi) coordinates.
  • Create a class named LineSegment . Its members should include pointers to two 2DPoint objects. It should have a method, Length(), that returns the length of the line segment.
Topic revision: r1 - 21 Jan 2018, ErkcanOzcan

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback