12
PC Programming N2NO Newbie-2-Novice-Outline Written By: Thomas G (08/2014) Feel free to use: no strings attached (text content only / images respectfully referenced) Table of Contents 1. INTRO .........................................................................................................................................................................................1 1.1 History ..........................................................................................................................................................................1 1.2 Object Oriented Programming (OOP) ............................................................................................................1 1.3 Language Comparisons .........................................................................................................................................2 1.4 Toolkits / Libraries .................................................................................................................................................2 1.5 Standards .....................................................................................................................................................................3 1.6 File Extensions ..........................................................................................................................................................3 1.7 Basics .............................................................................................................................................................................3 1.8 Suggestions .................................................................................................................................................................3 2. Data Models .............................................................................................................................................................................4 3. Open Source ............................................................................................................................................................................4 4. C & C++ ......................................................................................................................................................................................4 4.1 Compilers (GCC/MSVC) ........................................................................................................................................4 4.2 C++ ..................................................................................................................................................................................4 4.2.1 Header File .........................................................................................................................................................4 A. #Pre-processor directives ............................................................................................................................4 B. #Include/Using .................................................................................................................................................4 C. Namespace/Class/Struct/Union ..............................................................................................................5 4.2.2 Source File ..........................................................................................................................................................5 4.3 Details ...........................................................................................................................................................................6 4.3.1 Overview .............................................................................................................................................................6 4.4 Qt .....................................................................................................................................................................................7 4.5 Makefile ........................................................................................................................................................................7 5. C# .................................................................................................................................................................................................8 6. DLL/IDL/COM ........................................................................................................................................................................8 6.1 Component Object Model (COM) .....................................................................................................................9 7. VB6/VBA - Reference .......................................................................................................................................................10 7.1 VB(6&A) – Learned Items .................................................................................................................................10 1. INTRO Programs can be organized in two ways Around its code (what is happening) – Structured / Functional (Code acting on data) Around its data (who is being affected) – Object Oriented (Data controlling access to code)(Define the routines allowed to act on the data type) 1.1 History 1. Binary programmable computers (1937) (using front panel switches) 2. Electronic Numerical Integrator and Computer (ENIAC) – (1946 → 1955 ) The first electronic general purpose computer 3. Assembly Language – (1949) text/symbolic representation of binary programming 4. Structured Programming (stand-alone subroutines) FORTRAN (1950) COBOL (1959) BASIC (1964) Pascal (1970) C (1972) 5. Object Oriented Programming (OOP) LISP (1960) Simula (1967) SmallTalk(1972) FoxPro, C++, Delphi (1990s) OOP techniques became widely acceptance in all languages. Reference Language comparison http://en.wikipedia.org/wiki/Comparison_of_programming_languages Language list http://en.wikipedia.org/wiki/List_of_programming_languages Keywords Compared in Different Languages http://msdn.microsoft.com/en-us/library/zwkz3536%28v=vs.71%29.aspx List of Compilers http://en.wikipedia.org/wiki/List_of_compilers Online ISOCPP(IE. C++) compilers https://isocpp.org/blog/2013/01/online-c-compilers also see https://isocpp.org/get-started 1.2 Object Oriented Programming (OOP) 1. General Components Data Storage - Noun Variable – A named memory spot for holding data (Name → Value) Compound – Contains both code and data (e.g. Objects) Discrete – Only contains data Static – All objects share one memory location (IE. variable) Field – Alias for a public variable within a 'class' in OOP languages. Property – Wrapper for a field in OOP languages. Data Manipulation – Verb ( Any data manipulation code generally takes on any of the below names – technicality isn't maintained ) Function = In Data → Process → Out Data Method = Alias for Function in OOP Languages. Sub-routine = A function that does not directly return data Function Types Delegate = Call Wrapper – Function that receives a pointer to some other function (e.g. DelagateCaller(InData, PtrToFunction)) 2. Encapsulation = Data and function encapsulation within Classes and Structures ('struct') class = A defined and named block of code including variables(IE. Properties) and functions(IE. Methods) Classes bind together functions and data e.g. Class Circle { VARIABLES: 'radius', 'color', FUNCTIONS: getRadius(), getColor(), getArea() } struct = A class typically used for a data structure (User-defined Data Type (UDT)); where the variables within are public by default e.g. struct milk { brand, amount, grade }

PC Programming N2NO Programming N2NO Newbie-2-Novice-Outline ... FoxPro, C++, Delphi ... All objects share one memory location (IE. variable)

  • Upload
    hanhi

  • View
    243

  • Download
    5

Embed Size (px)

Citation preview

PC Programming N2NONewbie-2-Novice-Outline

Written By: Thomas G (08/2014) Feel free to use: no strings attached (text content only / images respectfully referenced)

Table of Contents1. INTRO.........................................................................................................................................................................................1

1.1 History..........................................................................................................................................................................11.2 Object Oriented Programming (OOP)............................................................................................................11.3 Language Comparisons.........................................................................................................................................21.4 Toolkits / Libraries.................................................................................................................................................21.5 Standards.....................................................................................................................................................................31.6 File Extensions..........................................................................................................................................................31.7 Basics.............................................................................................................................................................................31.8 Suggestions.................................................................................................................................................................3

2. Data Models.............................................................................................................................................................................43. Open Source............................................................................................................................................................................44. C & C++......................................................................................................................................................................................4

4.1 Compilers (GCC/MSVC)........................................................................................................................................44.2 C++..................................................................................................................................................................................4

4.2.1 Header File.........................................................................................................................................................4A. #Pre-processor directives............................................................................................................................4B. #Include/Using.................................................................................................................................................4C. Namespace/Class/Struct/Union..............................................................................................................5

4.2.2 Source File..........................................................................................................................................................54.3 Details...........................................................................................................................................................................6

4.3.1 Overview.............................................................................................................................................................64.4 Qt.....................................................................................................................................................................................74.5 Makefile........................................................................................................................................................................7

5. C#.................................................................................................................................................................................................86. DLL/IDL/COM........................................................................................................................................................................8

6.1 Component Object Model (COM).....................................................................................................................97. VB6/VBA - Reference.......................................................................................................................................................10

7.1 VB(6&A) – Learned Items.................................................................................................................................10

1. INTRO✔ Programs can be organized in two ways

◌ Around its code (what is happening) – Structured / Functional (Code acting on data)◌ Around its data (who is being affected) – Object Oriented (Data controlling access to code)(Define the routines allowed to act on the data type)

1.1 History 1. Binary programmable computers – (1937) (using front panel switches) 2. Electronic Numerical Integrator and Computer (ENIAC) – (1946 → 1955 ) The first electronic general purpose computer 3. Assembly Language – (1949) text/symbolic representation of binary programming

4. Structured Programming (stand-alone subroutines)◌ FORTRAN (1950)◌ COBOL (1959)◌ BASIC (1964)◌ Pascal (1970)◌ C (1972)

5. Object Oriented Programming (OOP)◌ LISP (1960)◌ Simula (1967)◌ SmallTalk(1972)◌ FoxPro, C++, Delphi (1990s) OOP techniques became widely acceptance in all languages.

✔ Reference◌ Language comparison http://en.wikipedia.org/wiki/Comparison_of_programming_languages ◌ Language list http://en.wikipedia.org/wiki/List_of_programming_languages ◌ Keywords Compared in Different Languages http://msdn.microsoft.com/en-us/library/zwkz3536%28v=vs.71%29.aspx ◌ List of Compilers http://en.wikipedia.org/wiki/List_of_compilers ◌ Online ISOCPP(IE. C++) compilers https://isocpp.org/blog/2013/01/online-c-compilers also see https://isocpp.org/get-started

1.2 Object Oriented Programming (OOP) 1. General Components

◌ Data Storage - Noun• Variable – A named memory spot for holding data (Name → Value)

• Compound – Contains both code and data (e.g. Objects)• Discrete – Only contains data• Static – All objects share one memory location (IE. variable)

• Field – Alias for a public variable within a 'class' in OOP languages.• Property – Wrapper for a field in OOP languages.

◌ Data Manipulation – Verb ( Any data manipulation code generally takes on any of the below names – technicality isn't maintained )• Function = In Data → Process → Out Data• Method = Alias for Function in OOP Languages.• Sub-routine = A function that does not directly return data

◌ Function Types• Delegate = Call Wrapper – Function that receives a pointer to some other function (e.g. DelagateCaller(InData, PtrToFunction))

2. Encapsulation = Data and function encapsulation within Classes and Structures ('struct')◌ class = A defined and named block of code including variables(IE. Properties) and functions(IE. Methods)

• Classes bind together functions and data• e.g. Class Circle { VARIABLES: 'radius', 'color', FUNCTIONS: getRadius(), getColor(), getArea() }

◌ struct = A class typically used for a data structure (User-defined Data Type (UDT)); where the variables within are public by default• e.g. struct milk { brand, amount, grade }

• TYPE keyword is used instead of 'struct' in VB6, VHDL and various other languages

◌ object = An isolated “copy” of the class code that maintains it's own variable values (IE. Instance of a class)• C1 = A named copy of 'circle class' code thus 'C1' can have it's own radius and color settings.• C2 = A named copy of 'circle class' code thus 'C2' can have it's own radius and color settings.• C3 = A named copy of 'circle class' code thus 'C3' can have it's own radius and color settings.• NEW keyword typically instantiates the object from a class design

** Above isn't actually how “classes/objects” work; but it represents the effect **** OOP languages use “vtables” behind the scenes to link-in the correct values for each object's variable values **Ex. One can drive “Object1” car without driving “Object2” & “Object3” cars even though they all derive from the same class (IE. design)

◌ Class Types▪ Concrete Classes = Classes defined for object creation▪ Abstract Classes = Classes that never become objects but are strictly used for inheritance

▫ C++ - Abstract classes contain at least one “pure virtual” function (to prevent objectifying it)▫ Example: Dog inherits Animal whereas just a plain 'Animal' object will never exist (Abstract is the common-ground of sub-classes)

▫ Interface = A particular type of abstract class that contains ONLY empty PUBLIC members that must be implemented (IE. Over-ridden)▫ Interface abstract classes do not contain any information or functionality; just a public interface▫ C++ does not have a keyword 'interface'; Typically, a class with ONLY “pure virtual”(IE. =0) functions is considered an 'Interface'▫ Java does have keyword 'interface'; In Java, classes can inherit multiple interfaces but only one other class

◌ Data Hiding▪ Public – Access allowed anywhere▪ Protected – Access allowed within the inheritance tree; keyword FRIEND is used in VB▪ Friend – In C++ a Friend Function can be defined as part of a class definition which allows that function access to private/protected class variables.▪ Private – Access allowed within the class

3. Inheritance = Method used to expand class functionality with “finer details” – Models a hierarchical classification◌ e.g. food (base class) → fruit (inherits 'food' class) → apple (inherits 'fruit' class)◌ Classes that inherit a “parent/base” class are called “derived classes”◌ Other Terminology identifying inheritance

▪ base → derived class▪ parent → child class▪ super → sub class

◌ Overloading = Same named functions with more than one implementation/functionality▪ Function Overloading = Two same-named functions with different arguments ( The caller argument count/type will determine which function implementation is used)▪ Operator Overloading = Overloading operators like <,>,=,+, and etc.. (e.g. iostream overloads '<<' and '>>' operators for 'cin' and 'cout')

◌ Overriding = One function implementation over-rides the previous version (Both having identical call names and arguments)▪ When an interface or abstract class is inherited and function bodies are defined in the derived class they actually override the empty body.

4. Polymorphism = Using the base class interface to access derived class objects◌ Using class inheritance a pointer to a derived class is compatible with a pointer to its base class◌ Polymorphism is the ability to access an object via it's base class inherited interface as its base class type

▪ Base Class Animal; Func Walk▪ Derived class Dog▪ Derived class Cat▪ Animal DogPointer = &Dog▪ Animal CatPointer = &Cat▪ DogPointer->Walk() We can call a base call using a pointer of base type even though Dog is of the derived dog class.

1.3 Language Comparisons Keywords

C/C++ VB6 / VBA Java

Struct Type

1.4 Toolkits / Libraries ✔ MS Visual Studio

◌ VS2012 and VS2013 do not have C++ GUI developers (by default but can still be brought up)◌ VS2010 C++ doesn't have intellisense◌ Windows Form Types

▪ Win32 = DLL or Win32 Applications (Using bare WinAPI)▪ ATL =▪ MFC = Microsoft Foundation Classes – Higher-level wrappers for Windows API for form design (unmanaged C++, native C++)▪ CLR/CLI = Common Language Runtime/Interface – Brings .NET framework (multi-language) to C++

◌ ATL = Active Template Library (C++ classes to simplify programming COM objects)

✔ C++◌ Core language (variables, data types, literals)

◌ C++ Standard Library (files, strings) – Functions for manipulating files and strings◌ Standard Template Library (STL) (std::) – methods for manipulating data structures (2.9+ may contain Boost libraries)◌ Boost◌ Cocoa (Mac)

✔ GUI Designers (Cross-Platform User Interface Toolkits)◌ Linux (MinGW) – Qt(KDE default DUI engine) / GTK(GIMP engine) / wxWidgets (MFC copy-cat in Dev-C++) / SDL◌ Windows – Blend / MFC / CLR

✔ Reference◌ GUI/Widget Toolkits – http://en.wikipedia.org/wiki/List_of_widget_toolkits (Often contain their own rendering engine)◌ Graphics Rendering Engines

▪ OpenGL▪ OpenVG▪ EGL▪ SDL = Simple DirectMedia Layer

1.5 Standards ✔ ANSI – Attempt to ensure C++ is portable

1.6 File Extensions

5. Object files◌ (.o) = Compiled source file (If you have several source files in your application, you will also have several object files.)

6. Libraries (Package of object files)◌ (.a ) – Linux / (.lib) – Windows = Static Library – Linked during compilation and become part of the executable◌ (.so) – Linux / (.dll) – Windows = Dynamic Library – Loaded only when program is running and library is called.

7. Runtime Library = Core functions and engine needed by a programming language compiler◌ Visual Basic Runtime = VBRUN60.DLL – Required for any compiled Visual Basic v6.0 compiled program to execute.◌

1.7 Basics 8. Development tool-chain = compiler and linker. 9. Fundamental data types (int, char, etc..) vs Compound data types (String,)

1.8 Suggestions ✔ Learn to take advantage or other code bases

✔ Note that the code is relatively static while the data is dynamic.✔ Naming Notations

◌ When Event name with 'On' like OnProgramStarted or OnButtonClicked()◌ Name Booleans as 'Is' like IsOkay or IsPathSet()

2. Data Models 1. XML

◌ Frankly, if you aren't having to describe/discover the data's type, XML is overkill. 2. JSON 3. YAML - All JSON is a valid YAML

✔ See http://en.wikipedia.org/wiki/Serialization✔ The process of serializing (encoding) an object is also called "marshalling" an object.✔ de-coding is "unmarshalling"

3. Open Source

4. C & C++ 1. C++ contains

◌ Text Editor◌ Compiler – (.h & .cpp) → (.o) – Includes a Pre-processor / Pre-Compiler that translates # items)◌ Linker – Links object code to missing functions (libraries)◌ Standard Library◌ Class Libraries◌ Debugger

4.1 Compilers (GCC/MSVC) ✔ GNU Compiler Collection (GCC) vs Microsoft Visual C++(MSVC)

◌ keyword 'abstract' is MS only◌ properties in C++ are MS only

✔ Pointer Unswizzling - is DE-referencing object pointers in memory before saving.✔ C++ Standard Library http://en.cppreference.com/w/cpp/header

✔ GCC = GNU Compiler Collection – An Integrated Compiler supporting multiple languages. (The abbreviation formerly stood for “GNU C Compiler”).◌ Current language support – GCC can compile programs written in any of these languages

▪ C – >gcc GNU C Compiler - Compiles (.c)(.cpp) as C and C++ respectively✔ gcc compiling ANSI C files contains less predefined macros.

▪ G++ – >g++ GNU C++ Compiler – Compiles (.c)(.cpp) both will be treated as C++✔ Compiles straight to object code no ANSI C code will exist✔ Automatically include the 'std' C++ libraries (gcc does not do this)

▪ Objective-C – C++ compiler for OSX and iOS (Apple) with the Cocoa Library; also adds messaging to the C language (.mm source code file extension)▪ Ada – >GNAT Described in separate manual▪ Fortran – Described in separate manual▪ Java – Described in separate manual▪ Treelang – Described in separate manual

◌ Expanded language support – Front-ends to GCC are installers that expand language support▪ Mercury▪ Pascal

4.2 C++

4.2.1 Header File// C++ source code is typically broken out into 2-text files (.h/.cpp)/************************************************************************************************************ (.h) Header files = Define the Interface ( Classes / Prototypes / Structure )* - #includes Inherited classes that are required* - structure declares Struct, class, union* - global prototypes Global (non-member) function signatures, constants and variables* - see also: http://embeddedgurus.com/barr-code/2010/11/what-belongs-in-a-c-h-header-file/************************************************************************************************************/

A. #Pre-processor directives// PRE-PROCESSOR directives = Source code manipuation before compilation(IE. code -> executable)

#ifndef MYHEADER_H // 'MYHEADER_H' = If pre-processor variable is not defined THEN#define MYHEADER_H // Set MYHEADER_H as defined and include code block (#if->#endif)

B. #Include/Using✔ <iostream> C++ standard library 'std' namespace = <stdio.h> in C

▪ New style #include doesn't necessarily represent a file-name (why .h was removed) the actual file is decoded by the compiler.▪ New header files = Includes with no (.h) and prefix of 'c' (e.g. <cstring>) and all 'c' prefixes are part of the 'std' namespace. (prevents name collisions)▪ “using namespace std” - puts the 'std' name-space into the global name-space for default non-name-space identified calls.

#include <stdafx.h> // #INCLUDE = Reference outside library code#include <iostream> //#include <string> //#include <array> // Standard Temploate Library(STL) Containers#include <vector> //#include <list> //#include <set> //#include <map> //#include <stack> //#include <queue> //

using namespace System; //------------------ SCOPE / TYPEDEF --------------------------------------------------------------------using namespace std; // using = Default namespace scope; Find commands in this namesapce if not specifically specifiedtypedef unsigned long ulong; // typedef = Name for existing type; typedef struct udt{...} is acceptable (e.g. ulong = "unsigned long")int inline InlineAdd(int a, int b) { // inline = Pre-Processor function declaration to be expanded to command-list where called

return a + b; }

C. Namespace/Class/Struct/Unionnamespace myspace { //------------------ BLOCK STRUCTURES -------------------------------------------------------------------

// namespace = Named block of top-level code (typically one namespace per project)// class = Named design containing data and/or function code (all members are 'private' by default)

class Arrays; // struct = Named class typically for data structures only (all members are 'public' by default)

union aunion; // union = Named single storage compartment having various data types associated with it (protocol usage)// --- Class Types ---

class AbstractABC; // ABC = Abstract base class cannot be initialized / objectified (1+ pure-virtual members)template<class T> class Concrete; // Concrete = a class that allows object instances (No pure-virtual members)class Interface { // Interface = An abstract-base-class(ABC) never having any functionality (All pure-virtual members)

public:virtual void Input(int) = 0; // virtual = allows the function to be over-ridden in a derived classesvirtual int Output() = 0; // pure-virtual = a member "func() =0" which makes the class abstract(ABC)

};

struct Fundamental_Data_Types { //--------------------- DATA TYPES ----------------------------------------------------------------------bool Abool; // Boolean = true/false 1-byteshort AShort; // Short = 32,767(+/-) 2-byteint AnInt; // Integer = 2,147,483,648(+/-) 4-bytelong ALong; // Long = 2,147,483,648(+/-) 4-bytefloat Afloat; // Float = E+/-38 ~7 digits 4-bytedouble Adouble; // Double = precision ~15 digits 8-bytechar AChar; // character = (1)ASCII character 1-byte others: char16_t, char32_t, wchar_t(2/4-byte)wchar_t AWChar;char Charray[5][5]; // arrays - Any data type can be a single[index] or multi[5][5] dimensional array.ulong ultype; // user-defined = typedef name (See 'typedef' above)

} FData; // ** Optionally ** classes, struct, and union can initiate objects(CSV) right away (e.g. 'FData' object)

struct STL_Containers {std::string name; // Multi-character stringsstd::vector<int> vect; // Dynamic array typestd::list<int> linklist; // Link liststd::set<int> aset; // Data Setsstd::map<string,int> amap; // Dictionary - Hash Tablestd::stack<string> astack; // Stackstd::queue<string> aqueue; // Queue

} STLCon;}//#endif

4.2.2 Source File/************************************************************************************************************ (.cpp) C++ source code "body" file* - File where header(.h) declaration are defined (over-riding the empty declarations)* -************************************************************************************************************/// #include <ThisFile.h>using namespace myspace;

class myspace::AbstractABC { //---------------------------- MEMBERS ------------------------------------------------------------------private: // private = members that are visible/accessible in-classprotected: string thewords; // protected = members that are visible/accessible in-class and derived-classespublic: // public = members that are visible/accessible everywhere

int LetterCount; // Field = public data membervirtual void Words(string in) { // Property(Set) = C++ doesn't natively support properties; use over-loading instead

this->thewords = in;} // this = pointer to the object instance currently being executedvirtual string Words() { // Property(Get) = OVER-LOADS function 'Words' (callers argument count/type determine which function to use)

return this->thewords;} // return = value returned by the call ('void'= no return value; 'string' in this case is type returned)virtual void Display() = 0; // Function() = pure virtual function

};

template<class T> // template<T> = Identifies 'data type' used in the class; set by the initializing callerclass myspace::Concrete : // [:] = Inherits

public Interface, // ***** NOTE: Variables cannot be initialized in the original class definitions *****public AbstractABC { //private: T iIn; // typename T = is the received template argument passed to this class @ initializationpublic: //

Concrete(int a) { iIn = a;} // Constructor = Gets called automatically when an object of this class is created (IE. 'new')~Concrete() { iIn = 0;} // Destructor = Gets called automatically when an object of this class is destroyed (IE. 'delete')void Input(T In) { this->iIn = In;} // Implement code-bodies for the Interface membersT Output() { return this->iIn; } //void Display() { // Implement code-bodies for the AbstractABC class - Only Display() is still a pure-virtual

std::cout << "Input = " << Output()<< "\n";std::cout << "Words = " << Words() << "\n";printf("Protected 'thewords' = %s\n",this->thewords);

}};

int main() //--------------------------------- Main() Start-up Function ----------------------------------------{

//---------------------------- Storage Specifiers ---------------------------------------------------auto Hi = "Hi there"; // auto = Initializing value automatically determine data type//extern Ext; // extern = object with external **linkage** defined in a different source file//mutable ConstChange; // mutable = data member that can be modified even if the containing object is constvolatile int HrdwIO; // volatile = a variable tied to a hardware register (changes w/o being set by code)static int iAllObjects; // static = One variable for all object instancesconst int CONST = 3; // const = Read only (can be applied to data types or classes)char hello[] = "Hello"; // Initial Bounds = array bounds are auto-set by initializing value.//int iarray[]; // Bound-less = Initialize a bound-less arraydecltype(Hi) Bye; // decltype = obtain data type for variable 'Hi'

//---------------------------- Value Assignments ----------------------------------------------------FData.ALong = 1L; // (Pre)(Suf)fix = Assignment values can have type identifiersFData.ALong = 07L; // 0 = Octal L = LongFData.ALong = 0x1UL; // 0x = Hex U = UnsignedFData.Afloat = 1.1E-24F; // E = ExponentF = FLOATFData.AChar = L'a'; // L = wchar_tFData.AChar = '\07'; // Char Octal 7

FData.AChar = '\xFF'; // Char Hex "FF"FData.AWChar = '\u00C0'; // Char Unicode ASCII character 0x03C0*/FData.Charray[0][0] = 'A'; //

FData.Adouble= (double)3; //----------------------------- Type Casting --------------------------------------------------------FData.Abool = bool(1); ////FData.Afloat = const_cast<int>(&3); // Type must be pointer, reference or pointer to member of an object//FData.ALong = dynamic_cast; // Must be pointer or reference to a complete class type//FData.AShort = reinterpret_cast; //FData.AnInt = static_cast<int>(3.3); //

Console::WriteLine(L"Main()"); // Believe 'Console' is Windows Only

int IntVal = 50; //----------------------------- NAME & POINTER addressing -------------------------------------------int *AddrPtr; // type [*] = declare pointer variablesprintf(" IntVal = %d\n", IntVal); // printf = ANSI C print to standard output (e.g. print the named variable 'IntVal')printf("&IntVal = %x\n", &IntVal); // [&] = AddressOfAddrPtr = &IntVal; // [=] = Assign (e.g. AddrPtr = AddressOf(IntVal))printf(" AddrPtr = %x\n", AddrPtr); //printf("*AddrPtr = %d\n\n", *AddrPtr); // [*] = Dereference pointer (IE. Return Value@Address)Concrete<int> myobj(111); // type 'name' = will auto-initiate a named objectConcrete<int> *ObjPointer; //ObjPointer = new Concrete<int>(3); // new = Initiate an un-named object at 'ObjPointer' addressmyobj.Display(); // [.] = call a named object memberObjPointer->Display(); // [->] = call a un-named pointer object member

STLCon.name = "Hello";std::cout << InlineAdd(2,3); //----------------------------- Flow Control --------------------------------------------------------for(int i = 0; i < 5; i++) { // for-loop = for(variable; loop again condition; per loop command) { commands }

if (i == 1) // ifSTLCon.name = "One\n";

else if (i == 2) // else ifcontinue; // continue = immediate next-iteration IE. skip the rest of the loop

else if (i == 4)break; // break = immediate exit IE. Exit the loop without finishing

else // else =if (i != 0)

STLCon.name = "Empty\n";try { // try = Error Handling routine

std::cout << STLCon.name; // cout = C++ send to standard output (e.g. standard output(console) receives STLCon.name)throw exception("My Exception"); // throw = Raise a runtime error

} catch (...) { // catch = Catch a runtime error; (...) = Catch 'ALL' exception errorsstd::cerr << "Something"; // cerr = Send to startard output 'err' pipe

}}for(char c : STLCon.name) { // for : = for each item in region

std::cout << "[" << c << "]";} //while (IntVal > 0 ) { // while

std::cout << IntVal << "\n";IntVal--;}

do { // do-whilestd::cout << IntVal++ << "\n";

} while (IntVal <= 5);switch (IntVal) { // switch-case

case 1: // casestd::cout << "One";break; // if 'break' is missing both 'case 1' block and 'default' block would execute when IntVal = 1

case 2: //std::cout << "Two";break;

default: // default = no 'break' were incountered (IE. no cases were satisfied)std::cout << "Not One or Two";

} return 0; // main return = '0' to the Operating System(OS) indicating a successful run}

4.3 Details ✔ int main() in C++ = int main(void) in C ('void' isn't required in C++)✔ '<<' (output operator) in C++ shifts something into 'cout' the screen - C uses printf() to print on screen (C++ supports printf also)✔ '>>' (input operator) in C++ 'cin' = standard input device

✔ Single value initial assignments◌ Type X(99); is the same as Type X = 99;

✔ char me[] = "String Literal"; //Which is a character array with terminator \0✔ void* - Any data type but must be defined before *✔ NULL = 0 or pointer that goes no-where

✔ Lambda functions are code blocks (IE. Like a function w/o a name)✔ auto is like template T but determines type automatically (need to look into this one a little more)

✔ Struct, Class, Union◌ struct – A UDT or Class generally used to declared plain data structures, can also be used to declare classes that have member functions, with the same syntax as with keyword class.

The only difference between both is that members of classes declared with the keyword struct have public access by default, while members of classes declared with the keyword class have private access by default. For all other purposes both keywords are equivalent in this context.

◌ Unions - is different from that of classes declared with struct and class, since unions only store one data member at a time, but nevertheless they are also classes and can thus also hold member functions. The default access in union classes is public.

Abstract base classes are something very similar to the Polygon class in the previous example. They are classes that can only be used as base classes, and thus are allowed to have virtual member functions without definition (known as pure virtual functions). The syntax is to replace their definition by =0 (and equal sign and a zero):virtual int function() = 0; // Is a pure virtual function in a abstract class (abstract class meaning it has a pure virtual function) and is only used as a abstract base class.

4.3.1 Overview✔ STL = Standard Template Library✔ Boost = Pre STL libraries

✔ Reserved ID naming◌ '__' and '_[A-Z]' - double underscore and underscore + capitol letter are reserved naming notations◌ '_*' - prefixed underscore is reserved at the global namespace; class and local naming is okay◌ is[a-z]* , mem[a-z]* , str[a-z]* , to[a-z]* , wcs[a-z]* are all reserved naming conventions and should not be used◌ E[A-Z]*, LC_[A-Z]* , SIG[A-Z]*, SIG_[A-Z]* are all reserved “macro” naming conventions and should not be used◌ C++ keywords are reserved

and break const double extern if new private signed template typeid void

and_eq case const_cast dynamic_cast false inline not protected sizeof this typename volatile

asm catch continue else float int not_eq public static throw union wchar_t

auto char default enum for long operator register static_cast TRUE unsigned while

bitand class delete explicit friend mutable or reintepret_cast struct try using xor

bitor compl do export goto namespace or_eq return switch typedef virtual xor_eq

bool

✔ Literals = integer, float, boolean, char or string constant✔ Notation = dec, oct, hex

Standard Variables

Data TypesName Description Size* Range*char Character or small integer. 1byte signed: -128 to 127

unsigned: 0 to 255+ addition

short int (short) Short Integer. 2bytes signed: -32768 to 32767unsigned: 0 to 65535

- subtraction

int Integer. 4bytes signed: -2147483648 to 2147483647unsigned: 0 to 4294967295

* multiplication

long int (long) Long integer. 4bytes signed: -2147483648 to 2147483647unsigned: 0 to 4294967295

/ division

bool Boolean value. (values: true or false) 1byte true or false % modulofloat Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits) CONDITIONALdouble Double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits) == Equal tolong double Long double precision floating point. 8bytes +/- 1.7e +/- 308 (~15 digits) != Not equal towchar_t Wide character. 2 or 4 bytes 1 wide character > Greater than

operators which can appear in C++. From greatest to lowest priority, the priority order is as follows: < Less thanLevel Operator Description Grouping >= Greater than or equal to1 :: scope Left-to-right <= Less than or equal to2 () [] . -> ++ -- dynamic_cast static_cast reinterpret_cast

const_cast typeidpostfix Left-to-right && AND

3 ++ -- ~ ! sizeof new delete unary (prefix) Right-to-left || OR* & indirection and reference

(pointers)? : Condition ? True : False

+ - unary sign operator ESCAPE CHARACTERS4 (type) type casting Right-to-left \n newline5 .* ->* pointer-to-member Left-to-right \r carriage return6 * / % multiplicative Left-to-right \t tab7 + - additive Left-to-right \v vertical tab8 << >> shift Left-to-right \b backspace9 < > <= >= relational Left-to-right \f form feed (page feed)10 == != equality Left-to-right \a alert (beep)11 & bitwise AND Left-to-right \' single quote (')12 ^ bitwise XOR Left-to-right \" double quote (")13 | bitwise OR Left-to-right \? question mark (?)14 && logical AND Left-to-right \\ backslash (\)15 || logical OR Left-to-right16 ?: conditional Right-to-left17 = *= /= %= += -= >>= <<= &= ^= |= assignment Right-to-left18 , comma Left-to-right

COMPOUND OPERATORS BITWISE OPERATORSexpression is equivalent to & AND Bitwise ANDvalue += increase; value = value + increase; | OR Bitwise Inclusive ORa -= 5; a = a - 5; ^ XOR Bitwise Exclusive ORa /= b; a = a / b; ~ NOT Unary complement (bit

inversion)price *= units + 1; price = price * (units + 1); << SHL Shift Left

>> SHR Shift Right

✔ Reference◌ CplusPlus Tutorial http://www.cplusplus.com/doc/tutorial/◌ Standard C++ Library Reference http://www.cplusplus.com/reference/ ◌

4.4 Qt ✔ Use CONFIG -= QT to omit all Qt libraries form the Qt Creator

◌ Had to un-install VS 6.0 to get to work; don't know why or how to get around it.◌ Add CONFIG += c++11 to your Qt .pro file for C11++ support.

4.5 Makefile 1. Variables

◌ NAME = VALUE◌ Special

• $@ = Name of the file to be made• $? = Names of the changed dependents

2. MS editions of Make is Nmake◌ Research also

• Visual Studio uses MSBuild• Nant scripts to automate build and test units (build server)

• 'devenv.exe' = make commands• '.vcproj' = Makefile• '.sln' = $(Make) IE. Root directory makefile will find recursively other makefiles whereas .sln has list of projects and dependancies• 'cl.exe' = 'g++' Compilers

3. about linux makefile

4. Line types: 5. -File dependancies 6. -shell commands 7. -variable assignments 8. -include statements 9. -conditional (loops & comments) 10.

• Extenting a line via \

Visual Studio make Utility

Command devenv.exe make

Compile and Link options

.vcproj Makefile

Dependency.sln has list of projects and dependencies

The root directory Makefile will recursively find other makefiles via the command $(MAKE)

Compiler cl.exe gcc, g++, c++ (or any other compiler, even cl.exe)

Linker link.exe ld (or any other linker)

• http://cognitivewaves.wordpress.com/makefiles/

5. C#✔ Features of C#

◌ Versioning◌ Generics◌ Delegates◌ Data Types

▪ Value Types – variables that directly contain a value (copies the contained value ie. a=b)▪ Reference Types – variables that contain a pointer to an object but not the object itself.

6. DLL/IDL/COM✔ DLL = Dynamic Link Library

◌ MS Windows registry “picks” the DLL file to use (See steps below)▪ Reference to 'C:\Lib.DLL'▪ Windows will read the GUID on 'C:\Lib.DLL'▪ Looks up the GUID in the windows registry▪ Registry GUID path → DLL is used (IE. If a new DLL with the same GUID has been registered then windows will use the \new\ one even if directly referenced to C:\Lib.DLL

✔ IDL = Interface Definition Language✔ COM = Common Object Model

◌ MS calls it ▪ OLE▪ ActiveX▪ DCE = Distributed Computing Environment – Originally by Open Software Foundations origins of COM/OLE/ActiveX and etc....

✔ Reference◌ Understanding Exported Code (DLLs, IDL, etc..) for VB6 http://whathesaid.ca/what-he-wrote/tame-visual-basic-with-idl/

Every component has an interface, which it has to implement. That interface do not carry any implementations of the methods: those are present in the CoClass (Component Class, ie COM Class Definition – the ‘class’ identifier in IDL). The Interface simply contains the method declarations. The interface is the only way a client can access the services of the component.Read more at http://www.devarticles.com/c/a/COM/COM-101-A-Quick-Primer/1/#ZmD8mreIzVrKXBbA.99

COM standardizes the instantiation (IE. creation) process of COM objects by requiring the use of Class Factories. In order for a COM object to be created, two associated items must exist:

As a result, COM Type Libraries were introduced, through which components can describe themselves. A type library contains information such as the CLSID of a component, the IIDs of the interfaces the component implements, and descriptions of each of the methods of those interfaces. Type libraries are typically used by Rapid Application Development (RAD) environments such as Delphi, Visual Basic or Visual Studio to assist developers of client applications.

RegFree COM (or Registration-Free COM) is a technology introduced with Windows XP that allows Component Object Model (COM) components to store activation metadata and CLSID (Class ID) for the component without using the registry. Instead, the metadata and CLSIDs of the classes implemented in the component are declared in an assembly manifest (described using XML), stored either as a resource in the executable or as a separate file installed with the component.[5] This allows multiple versions of the same component to be installed in different directories, described by their own manifests, as well as XCOPY deployment.[6] This technique has limited support for EXE COM servers[7] and cannot be used for system-wide components such as MDAC, MSXML, DirectX or Internet Explorer.

During application loading, the Windows loader searches for the manifest.[8] If it is present, the loader adds information from it to the activation context [6] When the COM class factory tries to instantiate a class, the activation context is first checked to see if an implementation for the CLSID can be found. Only if the lookup fails is the registry scanned.[6]

Now, when you create a COM component it can be of any of these types:

In-process Component: They are in form of (DLL's) Dynamic Link Libraries. They run in the memory space of your client application (that's why they are termed as in-process). If they crash they crash the entire client application with them as they operate in the same memory space as that of the client application.

Out-process Component: They are in the form of (EXE's) Executable's. They run in a different memory space as that of your client application (that's why they are termed as out-process). If they crash it doesn't affect the client application as they operate in a different memory space as that of the client application.

Remote Component: Remote components are just like any other component but the only difference is that remote components run from a separate remote location via a network. They are implemented using DCOM (Distributed COM).

COM components have a unique identity number. These numbers are stored in the registry under the HKEY_CLASSES_ROOT hive and a REVERSE lookup to the unique identifiers is stored in the HKEY_CLASSES_ROOT\CLSID sub folder. COM is, as I explained in its features, not just a specification on paper. It also includes various API's. It also includes some amount of system-level code. All ofthis is present in your COM runtime library.Read more at http://www.devarticles.com/c/a/COM/COM-101-A-Quick-Primer/1/#ZmD8mreIzVrKXBbA.99

There are mainly two types of interfaces:

Standard Interfaces: These are the interfaces provided by the COM library. Some of the standard interfaces are IUnknown, IDispatch, IClassFactory, IOle, IDataObject, IStream and IStorage.

Custom Interfaces: These are the interfaces created by you.Read more at http://www.devarticles.com/c/a/COM/COM-101-A-Quick-Primer/1/#ZmD8mreIzVrKXBbA.99

Calling external methods is called Marshalling an external method calls arguments.

.NET has its own COM tool known as???

Composed of:IDL – Interface definition language

Has Interfaces and Type LibrariesEach has it's own GUID (Global Unique IDentifier)

GUIDs are commonly called IIDs(Interface IDs) and LIBIDs(Type libraries)

CLSID – class ID?

Advantages -Enums and Types can be defined in IDL.

Questions to resolve:What is coclass GUID? - linked to implementation of a component

Visual Basic Data Type IDL Data Type

Boolean VARIANT_BOOL

Byte unsigned char

Collection _Collection*

Currency CURRENCY

Date DATE

Double double

Integer short

Long long

Object IDispatch*

Recordset _Recordset*

Single float

String BSTR

Variant VARIANT

no parameters voidFigure 2: Visual Basic data types and their corresponding data types in IDL

Other than unsigned char (Byte), keep in mind that VB can only implement signed types. Parameters marked as [in] use the IDL representation as in figure 1. These correspond to ByVal parameters in VB. Parameters marked as [in, out] add a single indirection operator (*). These correspond to VB’s ByRef parameters. For example:

HRESULT Method1( // ByVal As Integer [in] short intInParm, // ByVal As Object [in] IDispatch* objInParm, // ByRef As Integer [in, out] short* intInOutParm, // ByRef As Object [in, out] IDispatch** objInOutParm);

Windows DNA is short for Windows Distributed interNet Applications Architecture, a marketing name for a collection of Microsoft technologies that enable the Windows platform and the Internet to work together. Some of the principal technologies comprising DNA include ActiveX, Dynamic HTML (DHTML) and COM. Windows DNA has been largely superseded by the Microsoft .NET Framework, and Microsoft no longer uses the term. To support web based application Microsoft has tried to add internet features into the operating system using COM. But developing a web based application using COM based Windows DNA is quite complex. The complexity is due to the simple fact that Windows DNA requires the use of numerous technologies and languages. These technologies are completely unrelated from a syntactic point of view.

6.1 Component Object Model (COM)

Component Object Model (COM) is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages. The term COM is often used in the Microsoft software development industry as an umbrella term that encompasses the OLE, OLE Automation, ActiveX, COM+ and DCOM technologies.

Different component types are identified by class IDs (CLSIDs), which are Globally Unique Ident i fiers (GUIDs). Each COM component exposes its functionality through one or more interfaces. The different interfaces supported by a component are distinguished from each other using interface IDs (IIDs), which are GUIDs too.

COM interfaces have bindings in several languages, such as C, C++, Visual Basic, Delphi, and several of the scripting languages implemented on the Windows platform. All access to components is done through the methods of the interfaces. This allows techniques such as inter-process, or even inter-computer programming (the latter using the support of DCOM).Interfaces

All COM components must (at the very least) implement the standard IUnknown interface, and thus all COM interfaces are derived from IUnknown. The IUnknown interface

consists of three methods: AddRef() and Release() (which implement reference counting and control the lifetime of interfaces) and QueryInterface(), which by

specifying an IID allows a caller to retrieve references to the different interfaces the component implements. The effect of QueryInterface() is similar to

dynamic_cast<> in C++ or casts in Java and C#.

Notes from : http://www.youtube.com/watch?v=3ciT2uOz1kMNIC – Network interface card

Grids – Computers across the internet CORBA over IPCluster – Server rack or multiple racks all in one room

Theme – Has one Dispatcher and a lot of WorkersSETI@Home, BOINC, Render farms, Google clusters

✔ Reference◌ http://en.wikipedia.org/wiki/Component_Object_Model ◌ C++ and the COM Interface http://na.support.keysight.com/pna/help/latest/Programming/Learning_about_COM/c++_and_the_com_interface.htm ◌ C++ as an IDL http://g.oswego.edu/dl/mood/C++AsIDL.html◌

7. VB6/VBA - ReferenceTo write/read a file:

iFileHandler = FreeFile Open <filename> For Output As #iFileHandler Write #iFileHandler <string> Close #iFileHandler

Late Binding: Public Me as Object Me = CreateObject(<Class(name)>) Set Me = ObejctFromSomewhere that is type identified.

Early Binding: Public Me as New <ClassName>

Programming Tips & Debug:DLL will crash Excel w/o debugger if a String() is attempted to be cast to a variantAlways check 0/? In match to prevent crashes, IIF(lTopNum <> 0, lTopNum/lBotNum,0) doesn't work since IIF evaluates both True/False spots.

Determining if the IDE or VBA is being used.A trick to determining if the code is running in a compiled project or within an IDE is by using the Debug.Print command which is ignored when compiled.Example:

On Error Resume NextDebug.Print 1/0If Err = 0 then msgbox “running in a compiled project.”Else msgbox “running in debugger or vba”End if

Handy Windows APIPrivate Declare Sub Sleep Lib "kernel32" (ByVal lMilliseconds As Long)

7.1 VB(6&A) – Learned Items 1. Dealing with VB6 Data Types

a) ENUM - in classes CAN be shared from a dll to Office Applications

b) TYPE – you can share a type structure defined in VB6 but you CANNOT pass a Type structure variable from the DLL to VBA. • The only way to pass a variable of “Type” is to change it to variant->VBA->back to Type Structure.

c) ARRAYS• Arrays cannot be an optional argument – Use CSV or variant type to pass an optional array.• To check if an array is initialized use If ((Not Array) = -1) ‘Returns -1 if NOT initialized

• Above notation only works on base variable types, UDT (User-Defined Type Arrays will not work)• If an empty string array is cast into a variant the above will not flag correctly;

• Use LenB(Join(VariantArrayName)) = 0 to determine if a String() that is passed as a variant has been initialized.• Variants received as Non-Array Cannot be Cast to Array (Ex: variant = split(variant)) DOESN’T WORK.

• For this a second Variable Dim VariantArray() as ?? need to be setup and only If – Then structure will work • Example; If IsArray(Variant) Then VariantArray = Split(Variant) Else VariantArray = Variant

2. Unexpected differences between Compiled and Debugging VB6

a) Util.Average Throws a ‘Expression Too Complex’ during DLL debugging, but works OK when not debugging. b) If a Function returns a String() then a For Each <Variant> will cause a compiled DLLs to Crash Excel but not during VB6 debugging. c) Never Use On Error Resume Next during a Open FILE operation because EOF() is never reached (endless-loop) with a compiled DLL but works

with VB6 debugger.

3. Using Conditional Compilation Arguments a) Pre-Compilation Options (IE. #IF something THEN) can be set either locally or project globally.

• Local - Use #Const something = <Integer> will apply only to the class/Module.• Be careful since local #Const something = Can be a string BUT global ones can only be integers. (+/- are supported)

• Global - Use VB6 or VBA Menu item Project → Properties “Conditional Compilation Arguments” (Under Make Tab in VB6).• Example; See UseEmulator setting below which will set all #If UseEmulator = 1 Then Statements in all modules and classes. • Multiple items can be assigned by separating them with a (:)

4. Modifying at run time and Importing VBA Code automatically

a) The “CodeModule” of a VBComponent allows a lot of Source Code Control and Code changing.• Example – Item(5) = a module which is found by looping all the vbcomponents .Name property

• ThisWorkbook.VBProject.VBComponents.Item(5).CodeModule.CountOfLines• ThisWorkbook.VBProject.VBComponents.Item(5).CodeModule.Lines(1,10) ‘Dumps lines 1-10 of the module

1.2. Source code to Import from an HTTP location into VBA

Public Function Import(ByVal sModuleName As String) Dim oHTTP As Object, sFirstLine As String, sImportedModName As String, lCnt As Long, bExists As Boolean Dim oNewComponent As VBComponent, sLine As String, sLines() As String, lLineCnt As Long, bInBEGIN As Boolean If LCase$(Left$(sModuleName, 7)) = "http://" Then Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP") Call oHTTP.Open("GET", sModuleName, , "testdevRpt", "p3T)zpko") Call oHTTP.send("") sLines = Split(oHTTP.responseText, vbLf) For lLineCnt = 0 To IIf(UBound(sLines) > 30, 30, UBound(sLines)) If Left$(sLines(lLineCnt), 9) = "Attribute" Then '//If Attribute Line check for Module Name If InStr(1, sLines(lLineCnt), "Attribute VB_Name =") > 0 Then sImportedModName = Trim(Replace(Replace(Replace$(sLines(lLineCnt), "Attribute VB_Name = ", ""), """", ""), Chr(13), "")) sLines(lLineCnt) = "" '//Blank out Attribute lines End If If Left$(sLines(lLineCnt), 7) = "VERSION" Then sLines(lLineCnt) = "" If Left$(sLines(lLineCnt), 5) = "BEGIN" Then bInBEGIN = True If bInBEGIN And Left$(sLines(lLineCnt), 3) = "END" Then: bInBEGIN = False: sLines(lLineCnt) = "" If Left$(sLines(lLineCnt), 1) = "'" Then Exit For If bInBEGIN Then sLines(lLineCnt) = "" Next With ThisWorkbook.VBProject.VBComponents For lCnt = 1 To .count If LCase$(Trim(.Item(lCnt).name)) = LCase$(sImportedModName) Then MsgBox "Module '" & sImportedModName & "' already exists in this job." bExists = True End If Next If Not bExists Then Set oNewComponent = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule) oNewComponent.name = sImportedModName oNewComponent.name = "Datalog" oNewComponent.CodeModule.AddFromString Join(sLines, vbLf) End If End With End If Set oHTTP = NothingEnd Function

5. Grabbing object from Excel VBA into VB6 automatically (TheHdw & TheExec) without passing the object. a) Note: The VBA call function that returns the object must be a function (IE. It cannot be a property get) If TheHdw Is Nothing Or TheExec Is Nothing Then 'vvv[ Get TheHdw & TheExec Objects from Excel ]vvvvvvvvvv Dim ExApp As Excel.Application Set ExApp = GetObject(, "Excel.Application") Set TheHdw = ExApp.Run("tl_tm_GetTheHdw") Set TheExec = ExApp.Run("tl_tm_GetTheExec") Set ExApp = Nothing '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^End If

6. Excel crashes when VB6 DLL Module has global names conflict with VBA names a) Its always a good idea to make VB6 modules “Private” to the VB6 Project.

Option ExplicitOption Private Module '//Prevent module clashes with Excel VBA - Keeps Module private to this Project.

7. Notes about VB6 Events (IE. Private WithEvents OBJ as CLS & Public Event Something()) a) Events CANNOT be handled in a Module (Must be contained in classes)

• Object that trigger or handles Events must be put into a class.• Objects must be early-binded (late-binding doesn't cause events to trigger)• The class containing the Handling object “Public WithEvents OBJ as CLS” must also contain all Event handlers

• An object with events cannot be passed into a class that handles the events• All object variables must reside in the same class with the event handling subs.

• Event handler subs can objects CAN be Private• Any object variable “WithEvents” cannot be assigned within a TYPE structure.

b) When events don't work (something is out of place) – there is no error trapping/messages available that I know of.

8.