Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,
I want the codes to draw circle, dot, line and ellipse in c++ with switch structure, please.
Posted
Comments
OriginalGriff 13-Dec-11 14:51pm    
Have you tried anything at all yourself?
Sergey Alexandrovich Kryukov 13-Dec-11 14:58pm    
It's good that OP did not try it -- please see my answer.
--SA
Sergey Alexandrovich Kryukov 13-Dec-11 14:56pm    
Why?
--SA

1 solution

Doing it with switch is a huge abuse of C++ as an object-oriented language.

You should create an abstract base class like Shape and derive the classes Line, Ellipse, Rectangle and more. Better don't include Point in the hierarchy as it cannot have the same rendering. Instead, create a structure Location and make an instance of it a member of Shape. Don't include Circle and Square as they would work much better as special cases of Ellipse and Rectangle, just add special constructors and/or factory methods.

…I feel I'm wasting my time. What you really need is to read some elementary manuals on C++ and OOP.

—SA
 
Share this answer
 
v2
Comments
[no name] 13-Dec-11 14:58pm    
You do not wasting your time! You are helping us keep things clear!
And also the different elementary manuals do not correspond on such aspects :)
Regards
Sergey Alexandrovich Kryukov 13-Dec-11 15:32pm    
Thank you for your good words!
--SA
[no name] 13-Dec-11 15:38pm    
Lot of times I have problems (self made…) with your (sometimes hard) comments. But with a little bit distance, most time I have to say to me; this –SA is really an expert.
So please keep on sharing your knowledge...and maybe become a liitle bit more soft with beginners (also like me) Thx.
Regards
Sergey Alexandrovich Kryukov 13-Dec-11 16:02pm    
Thank you again. I really appreciate your advice. I'm from much more demanding type of culture and I have a lot of positive experience of its efficiency, that's why. You should understand that on a personal level I'm very benevolent. It needs some social experience to understand the difference.
--SA
[no name] 13-Dec-11 16:16pm    
Many thanks to you for your engagement/employment here...(sorry english is not my native lng, hope you will understand it what I try to say). I think I will learn how to become compatible. So let's go and let us learn.
Regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900