Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which is best for Desktop Apps VFP?.NET
Message
From
02/02/2004 06:21:40
 
 
To
02/02/2004 05:41:44
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00860600
Message ID:
00872882
Views:
72
Walter,

>> What you do there is casting, and this indeed is a feature found in
>> strict type languages. I was refering to constructs where strong typing >> is used to validate the type where a parameter might be of unknown class.
>> For flexible and optional parameters in functions you've got to use
>> overloading in C++.

C++ allows you to determine type using RTTI.
#include <iostream>
#include <typeinfo.h>

class MyBase {
public:
   virtual void myfunc() {}
};

class AnotherClass : public MyBase {};

using namespace std;

int main()
{
   AnotherClass* pAnother = new AnotherClass;
   MyBase* pMyBase = pAnother;

   cout << typeid(pMyBase).name()   << endl;      
   cout << typeid(*pMyBase).name()  << endl;   
   cout << typeid(pAnother).name()  << endl;   
   cout << typeid(*pAnother).name() << endl;   

   delete pAnother;
}
For flexible parameters you can use void or universal pointers which is quite a common approach in the Win32 API. You don't have to use overloading and can still determine type information.

Regards
Neil
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform