enum (Enumeration)

Using Enum enum name {enumeration list} optional varaible(s); Examples enum colour_type {red, green, blue} colour; //The variable colour can only be assigned the values red, green or blue (red = 0, green = 1, blue = 2 will be done by the compiler – these are basically const values) enum colour_type {red, green = 9, […]

Read More

Const

const int BUF_SIZE = 512; static const int BUF_SIZE = 512; //Static is needed when defining at class level #define may also be used, e.g.:- #define VIDEO_LOG_PATH “C:\\Video_Log_Archive” const objects are local to a file by default Unlike other variables, const variables declared at global scope are local to the file in which the object […]

Read More

Array Functions

Array Class Type Array:: to get all the members of the Array class you can use Clear array Array::Clear(arrayName, 0, araryName->Length); //(name, start index, number of indexes to erase) Copy Array Array::Copy(Source, Dest, Length); //This will work with multi dimension arrays also Increase Array Size Array::Resize(myArr, myArr->Length + 5); //Resize the array to a bigger […]

Read More

.Arrays (Vectors)

Modern C++/CLI programs should almost always use vectors and iteriators in preference to the lower-level arrays and pointers, and strings to replace C-style array based character strings. Well designed programs use arrays and pointers only in the internals of class implementations where speed is essential. As well as being less powerful, C-style strings are the […]

Read More

Const Static Arrays

You can create constant arrays no problem and can do it at class level like this in the class variable area: static array<String^> ^MyStringrray = {"Name 1", "Name 2"}; static array<int> ^MyIntArray = {111, 222}; static array<UInt16> ^wCRCTable = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, […]

Read More

Target Platform

C++ does not have the Target Platform target option found in VB and C# because it is compiled to machine code that is platform specific.  Therefore the AnyCPU (as opposed to x64 and x86 options) isn’t available. If you get “class not registered” errors with COM objects that are 32bit only, but you’ve checked you […]

Read More

Typedef

A typedef lets you use a synonym (another name) for a type. E.g. typedef double wages; typedef int exam_score; typedef wages salary;

Read More

Cast

Cast – Converting a variable to a different type in an operation (int*) Although necessary at times, casts are inherently dangerous (becuase you don’t get a compiler warning that a potentially bad conversion will occur). It is more nomral to just allow C++ to do its normal automatic conversion which will typially involve increasing the […]

Read More