Click here to Skip to main content
15,891,828 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get exe Pin
Cedric Moonen8-Dec-09 20:28
Cedric Moonen8-Dec-09 20:28 
Questionhow does an uninstall exe delete itself? Pin
includeh108-Dec-09 19:02
includeh108-Dec-09 19:02 
AnswerRe: how does an uninstall exe delete itself? Pin
o m n i8-Dec-09 20:47
o m n i8-Dec-09 20:47 
GeneralRe: how does an uninstall exe delete itself? Pin
includeh108-Dec-09 21:36
includeh108-Dec-09 21:36 
GeneralRe: how does an uninstall exe delete itself? Pin
David Crow9-Dec-09 2:17
David Crow9-Dec-09 2:17 
AnswerRe: how does an uninstall exe delete itself? Pin
David Crow9-Dec-09 2:19
David Crow9-Dec-09 2:19 
QuestionInheritance!!! Pin
Nilesh Hamane8-Dec-09 18:58
Nilesh Hamane8-Dec-09 18:58 
AnswerRe: Inheritance!!! Pin
Cedric Moonen8-Dec-09 20:26
Cedric Moonen8-Dec-09 20:26 
Before answering your question, I think there should be a small modification in your code of the Cpolygon class: you should have a virtual area function:
class Cpolygon
{
...
virtual int area() = 0;
};   


Otherwise those two lines won't compile:
cout<<Poly1->area()<<endl;
 cout<<Poly2->area()<<endl;


First question: you have two pointers to a base class and you make them point to derived classes. This would be more or less similar as this:
Cpolygon *Poly1 = new Crectangle();
 Cpolygon *Poly2 =new Ctriangle();


Which is seen more often.

In fact the whole purpose of this code is to show you the use of polymorphism (I suggest you google for it to have a lot more examples). The base principle is that you can manipulate objects of different types (Crectangle and Ctriangle) exactly the same way: they all implement a known interface (Cpolygon). This way, you can store them all in a container and you don't need to know which exact type you are manipulating. Each time you call a virtual function (like area()), it will be "redirected" to the correct type. This is one of the most basic and fundamental principle of object oriented programming.

Cédric Moonen
Software developer

Charting control [v2.0]
OpenGL game tutorial in C++

AnswerRe: Inheritance!!! Pin
cheetach8-Dec-09 20:28
cheetach8-Dec-09 20:28 
QuestionCombination C and OpenGL: Making a loop to draw circles [modified] Pin
Chidori-chan8-Dec-09 18:46
Chidori-chan8-Dec-09 18:46 
AnswerRe: Combination C and OpenGL: Making a loop to draw circles Pin
LunaticFringe8-Dec-09 19:43
LunaticFringe8-Dec-09 19:43 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles Pin
Chidori-chan8-Dec-09 20:35
Chidori-chan8-Dec-09 20:35 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles Pin
Cedric Moonen8-Dec-09 20:42
Cedric Moonen8-Dec-09 20:42 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles Pin
Chidori-chan8-Dec-09 20:58
Chidori-chan8-Dec-09 20:58 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles Pin
Tim Craig8-Dec-09 20:52
Tim Craig8-Dec-09 20:52 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles [modified] Pin
Chidori-chan8-Dec-09 21:29
Chidori-chan8-Dec-09 21:29 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles Pin
LunaticFringe9-Dec-09 3:42
LunaticFringe9-Dec-09 3:42 
GeneralRe: Combination C and OpenGL: Making a loop to draw circles Pin
Chidori-chan9-Dec-09 13:07
Chidori-chan9-Dec-09 13:07 
AnswerRe: Combination C and OpenGL: Making a loop to draw circles Pin
Cedric Moonen8-Dec-09 20:18
Cedric Moonen8-Dec-09 20:18 
QuestionWhy CDC::LineTo(pt) draw a line not include pt Pin
fitatc8-Dec-09 17:49
fitatc8-Dec-09 17:49 
AnswerRe: Why CDC::LineTo(pt) draw a line not include pt Pin
Richard MacCutchan8-Dec-09 22:06
mveRichard MacCutchan8-Dec-09 22:06 
GeneralRe: Why CDC::LineTo(pt) draw a line not include pt Pin
fitatc9-Dec-09 14:43
fitatc9-Dec-09 14:43 
GeneralRe: Why CDC::LineTo(pt) draw a line not include pt Pin
Richard MacCutchan9-Dec-09 23:18
mveRichard MacCutchan9-Dec-09 23:18 
GeneralRe: Why CDC::LineTo(pt) draw a line not include pt Pin
fitatc10-Dec-09 13:34
fitatc10-Dec-09 13:34 
QuestionDe Boor method to draw Bspline ?? Pin
a04.lqd8-Dec-09 16:54
a04.lqd8-Dec-09 16:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.