Virtual?
First of all, since this is my first post here I want to say thanks to the people who run this site. I am a senior CS major, and I''ve been wondering when I was going to learn the REAL stuff. Good thing I happened to come here. I read the reviews on Andre LaMothe''s "Tricks of the Windows Game Programming Gurus", and on their advice I decided to buy it... in three days I have learned more on programing than the last three years of college. In particular, his explanation of Windows32 programming helped me greatly, as I knew nothing about it from school. However, I had a question on something I am reading that I don''t understand.
He uses a lot of C, whereas I am entirely trained (in the order I learned them) in Basic, Pascal, C++, Ada, VC++. I don''t know a lot of the old C stlye commands, so I guess it is making it hard to understand some of LaMothe''s code (although, as the people here said, he is very good at explaining his code). One part I don''t understand is:
virtual void _stdcall fx(void) = 0;
The main problems I am having with this are the parts "virtual", "_stdcall", and I am also wondering why he put "void" as a parameter to the function "fx" (at least it appears that way), and then why (or how he even can) set it equal to anything, in this case 0.
Thanks in advance for any help, I greatly appreciate it.
-John Dowis
As far as I know the keyword ''virtual'' is only part of c++, so I don''t know what that''s about.
_stdcall is a calling convention, it''s used to determine how arquements are passed to a function, _stdcall is used in windows programs alot, usualy as a macro such as WINAPI, CALLBACK and the like.
The void, in C, tells the compiler that there are no arguements to the function. Otherwise, any number of of them can be passed without an error.
_stdcall is a calling convention, it''s used to determine how arquements are passed to a function, _stdcall is used in windows programs alot, usualy as a macro such as WINAPI, CALLBACK and the like.
The void, in C, tells the compiler that there are no arguements to the function. Otherwise, any number of of them can be passed without an error.
= 0 means its pure virtual, so if you derive a class you have to have fx(void) in your class. the compiler will give you an error if you don''t
quote: Original post by John Dowis
virtual void _stdcall fx(void) = 0;
Thats definitely not C. If it is C++, then that means it is a pure virtual member function . Look it up in your favourite C++ book, or if you're lucky some other forum goer will tell you all about polymorphism. I would, but i think a book (or someone else) would do a better job explaining it than i could.
[edited by - sark on January 19, 2003 12:58:33 AM]
Virtual means that say you had a code like this:
class cPlayer{\\Class player
void punch();Function punch within class player
}player1;
cplayer public:cKnight{\\derived class from cplayer
virtual void punch(); \\Now instead of using the punch
\\From cPlayer it uses the new punch from
\\cKnight which is different
This will probably help if you know about derived classes but if not sorry I''m tired of thinking
Favorite Quotes:
Gandalf: You shall not pass.
Smeagol: My Precccious!
Smeagol: My little hobbitses
Can you tell i''m a lotr fan!!!
I hope so.
class cPlayer{\\Class player
void punch();Function punch within class player
}player1;
cplayer public:cKnight{\\derived class from cplayer
virtual void punch(); \\Now instead of using the punch
\\From cPlayer it uses the new punch from
\\cKnight which is different
This will probably help if you know about derived classes but if not sorry I''m tired of thinking
Favorite Quotes:
Gandalf: You shall not pass.
Smeagol: My Precccious!
Smeagol: My little hobbitses
Can you tell i''m a lotr fan!!!
I hope so.
Favorite Quotes:Gandalf: You cannot pass!|Smeagol: We don't need you!|Sloth: Hey you guys!|
quote: Original post by SSJCORY
Virtual means that say you had a code like this:
class cPlayer{\\Class player
void punch();Function punch within class player
}player1;
cplayer public:cKnight{\\derived class from cplayer
virtual void punch(); \\Now instead of using the punch
\\From cPlayer it uses the new punch from
\\cKnight which is different
This will probably help if you know about derived classes but if not sorry I'm tired of thinking
On second thoughts, maybe there are people who could explain polymorphism worse than i could...
[edited by - sark on January 20, 2003 3:21:02 AM]
quote: Original post by sark
On second thoughts, maybe there are people who could explain polymorphism worse than i could...
...LOL...
Update GameDev.net system time campaign:
''date ddmmHHMMYYYY''
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
quote: Original post by John Dowis
Is _stdcall and WINAPI the same thing?
According to windef.h, amidst an ugly assortment of #ifdef''s, is:
#define WINAPI __stdcall
class SomeClass{public: virtual int GetClassType(){return 1;}};class Class1 : public SomeClass{public: int GetClassType(){return 10;}};class Class2 : public SomeClass{public: int GetClassType(){return 100;}};SomeClass Instance_SomeClass;Class1 Instance_Class1;Class2 Instance_Class2;int Var1 = Instance_SomeClass.GetClassType(); // Var1 will be "1"int Var2 = Instance_Class1.GetClassType(); // Var2 will be "10"int Var3 = Instance_Class2.GetClassType(); // Var3 will be "100"
I'm not very familiar with class inheritance but I hope this will help
you get started...
[Edit] Fixed a very little thing in the classes.
KaMiKaZe
[edited by - Kamikaze15 on January 20, 2003 8:40:24 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement