Arrays In A Class

Resizing An Array Of Objects In A Class It won’t work. Best approach usually is to use a list instead of an array. Alternatively you have to copy the array to a new array with a different size using Array::Copy Array::Copy(obj->ClassValueArray1, ClassValueArray1, NewSize);

Read More

Copy A Class

Copying A Class If your class has no pointer and no dynamic memory allocation then you don’t need to provide a copy function – you can use ‘=’. However if this isn’t true (i.e. your class contains a string or other object), then you need to provide a copy function or otherwise if you try […]

Read More

.Classes (& Struct) General

Objects represent the people, places and things in your program. For example individual invoices sent and invoices received are invoices. Classes are the units of code you write to make objects come to life in your program. You write classes but you think in terms of objects (its why its called object orientated programming). Think […]

Read More

Adding new class to a form

Form designer won’t allow you to add new classes before the main form class. In fact you can place a class before the forms main class no problem for the compiler – its just the form editor that won’t have it (you can’t view the form in design view) To solve this you need to […]

Read More

Forward Declarations Of A Class

When you use references to a class in another classes header file (e.g. becuase the class uses the other class objects in function calls or as objects for its own use) then instead of including the other classes header file in the .h file, use the following forward class declaration instead: ref class OtherClassName; (Typically […]

Read More

Creating Basic Class / Struct

ref class and ref struct are the same thing. You could replace class with struct below, but no-one uses struct. Define a structure public ref class DOCINFO { public: String ^DocumentName; String ^OutputFile; int ^TheValue; }; If You Need A Constructor //—– CONSTRUCTOR —– public: DOCINFO::DOCINFO() { DocumentName = “”; OutputFile = “”; } Use […]

Read More

Structures/Class Of Our Own Data Types

Often with a class you want the application to use structures or variables that can be passed to the classes functions to be read or written with data. There is no real difference between a class or structure in c++.NET so create the structure as a class. In the header file of a class create […]

Read More

Global Class Objects

Creating A Global Class Often its useful in an application to be able to use an object from anywhere. On first attempts this seems impossible for managed classes, but the solution is to use a class declared at the global level and have it contain the object you want to access from everwhere. Add To […]

Read More

Create A New Class

To create A new class, which will create the .cpp and .h files: Project > Add Class > C++ Class Typically: Specify the class name.  You don’t need to provide a base class. Select public and select managed. In the new .h file add the following: The namespace can be a distinct name, or for […]

Read More