1 Replies - 369 Views - Last Post: 08 December 2010 - 03:06 AM Rate Topic: -----

#1 Tiancailee  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 04-December 10

Classes

Posted 08 December 2010 - 02:58 AM

Hi i am trying to think of how the algorithm of how this question works but no matter how hard i tried, i cant think of it. Can anyone give me a hand?? Any help or tip would be greatly appreciated.

Question:

Given 3 classes, equilateral triangle, isosceles triangle and right-angled
triangle, find the relationship in terms of inheritance among them and a
generic triangle class. Define each class’s data members and member
functions, making clear which are mutator, accessor, or virtual functions.
Write functions to calculate area and perimeter, sharing code as much as
possible.

Is This A Good Question/Topic? 0
  • +

Replies To: Classes

#2 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 109
  • View blog
  • Posts: 1,530
  • Joined: 25-January 07

Re: Classes

Posted 08 December 2010 - 03:06 AM

The base class for all these 3 triangle types is a triangle! and the common properties of it are the length of 3 sides of the triangle (and all 3 angles may be if you want)!!! Now you can head forward to identify what are methods required in all these classes.

I hope this will help you. :)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1