quote: Original post by John Dowis
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"
virtual is a C++ keyword to indicate which functions will be despatched dynamically. If a function is virtual, it means that the actual function which gets called is determined at runtime, according to the dynamic type of the object receiving the function call. For example, if you have this simple hierarchy:
class B{public: virtual void foo() { /* ... */ }};class D : public B{public: void foo() { /* ... */ }};
Public inheritance of B indicates that you can use a D wherever a B is expected, since D implements a superset of B''s behaviour.
Then, say you have this code:
B *b1 = new B;B *b2 = new D; // a B is expected, but create a Db1->foo();b2->foo();
Since foo is marked as virtual, it will get despatched based on the dynamic type of the object. The dynamic type is what appeared on the right-hand side of the new expression. So, for b1->foo(), B::foo gets called and, for b2->foo(), D::foo gets called. This is a limited form of polymorphism, known as "subtype polymorphism".
quote:
"_stdcall"
When a function gets called, there are many ways of passing parameters. Pretend you have this function signature:
int foo(int x, int y);
Where do the x and y get their values from? How does the callsite know how to retrieve the return value? You might push y onto the stack, followed by x, and then have foo pop them back off. Or you might push x followed by y. You might put them into registers, or indirect via a memory location. There are many permutations of how you might do this, and "stdcall" denotes one way of doing it. Check out your compiler''s documentation to find out more.
quote:
I am also wondering why he put "void" as a parameter to the function "fx"
Because he''s into C habits. It''s not necessary in C++.
quote:
why (or how he even can) set it equal to anything, in this case 0.
That confusing syntax is not an assignment. If a function declaration in a class is followed by "=0", it means the function is "pure virtual". Pure virtual means "any classes which inherit me *must* implement this function if they are to be instantiated". If an implementation of the function is not provided, then an attempt to create an instance will fail, i.e. the class is "abstract".
BTW, this is all basic C++, not C. I suggest that you ask whoever "entirely trained you in C++" for your money back.