designing shape class with circle and triangle
I am trying to understand the is-a vs is-like-a relationship where I read somewhere that we must try to follow design such that we always have is-a relationship and not is-like-a. Consider the classic example of shape base class and derived triangle and circle classes. So circle is-a shape and so is triangle is-a shape. The function display area was defined in the base class. Now the below program runs fine. #include "stdafx.h" #include <cmath> #include <iostream> class shape { public: virtual void displayArea()=0; }; class circle :public shape { int radius; public: circle(int radius2) :radius
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.