IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesC++/CLI  Print This     

Destructor (C++/CLI and Access VBA Cross Reference Guide)

By Mike Prestwood

C++/CLI versus Access VBA: A side by side comparison between C++/CLI and Access VBA.

 
OOP Details
 

More object oriented (OO) stuff.

Destructor

[Other Languages] 

General Info: Class Destructor

A special class method called when an object instance of a class is destroyed. With some languages they are called when the object instance goes out of scope, with some languages you specifically have to call the destructor in code to destroy the object, and others use a garbage collector to dispose of object instances at specific times.

Desctructors are commonly used to free the object instance but with languages that have a garbage collector object instances are disposed of when appropriate. Either way, destructors or their equivalent are commonly used to free up resources allocated in the class constructor.

Languages Focus

Are object instances freed with a garbage collector? Or, do you have to destroy object instances.

C++/CLI:  "Finalizer" ~ClassName

Unlike standard C++, C++/CLI uses the .Net garbage collector to free managed object instances. Prism does not have nor need a true destructor.

In .Net, a finalizer is used to free non-managed objects such as a file or network resource. Because you don't know when the garbage collector will call your finalizer, Microsoft recommends you implement the IDisposable interface for non-managed resources and call it's Dispose() method at the appropriate time.

More Info / Comment
Access VBA: 

When an object instance is destroyed, Access VBA calls a special parameter-less sub named Class_Terminate. For example, when the variable falls out of scope. Since you cannot specify parameters for this sub, you also cannot overload it.

To explicitly destroy an object, use Set YourClass = nothing.

When an object instance is created from a class, Access VBA calls a special sub called Class_Initialize.

More Info / Comment  












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]