Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which is best for Desktop Apps VFP?.NET
Message
De
02/02/2004 06:21:40
 
 
À
02/02/2004 05:41:44
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00860600
Message ID:
00872882
Vues:
76
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform