Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New VB Features
Message
De
13/10/2000 15:29:39
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00425458
Message ID:
00429323
Vues:
15
>>>Albert,
>>>
>>>I was speaking from purely a VFP POV when interfacing with a DLL requiring a structure.
>>
>>I thought it was clear that I understand that. I was just pointing out an exception to the rule. I also understand that the member function do not exist in the structure, just as they do not exist in the memory image of a C++ class. In C++ a class and a struct are the same except for the default visibility of the members. This default visibility is why the common practice of placing public: before private: in C++ class declarations is discouraged. If you mistakenly leave out the private: following a public:, all of the members that you intended to be private will be public. If you err in the other way, the compiler will throw errors that will notify you of your mistake.
>
>I disagree. A class and a struct in C++ are not the same. For example, a class has a constructor and destructor. A struct does not. It could be argued that, from an abstract POV, the compiler provides the default constructor and destructor for a struct, but the programmer has no access to these. In a class, however, the programmer does have access to them and may provide default values. To me, this is a significant difference.

This compiles...
const short kMaxNameSize = 20;

struct Employee
{
	// Data members...
   char   Name[ kMaxNameSize ];
   long   ID;
   float  Salary;

   // Member functions...
   void   Print();
   Employee();
   Employee(long ID);

	private:
    int SecretCode;
};

Employee::Employee()
{
	SecretCode = 0;
}

Employee::Employee(long newID)
{
	SecretCode = newID;
	ID = newID;
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform