#include class myClass // How to define a "class" type { // This is NOT a variable definition public: int i; // It serves to tell C++ what "myClass" looks like float f; }; myClass x; // How to define class variables int main(int argc, char *argv[]) { myClass A[3]; // How to define arrays of class variables extern myClass x; // How to DECLARE class variables void Print1(myClass); // How to pass class by VALUE void Print2(myClass &); // How to pass class by REFERENCE x.i = 1234; // How to use a struct variable x.f = 3.14; Print1(x); Print1(x); A[1].i = 333; // How to use an array of struct variable A[1].f = 2.17; Print1(A[1]); Print2(x); Print2(x); } /* ---------------------------------------------- How to pass class variables by VALUE ---------------------------------------------- */ void Print1(myClass h) { cout << "Structure values = (" << h.i << ", " << h.f << ")\n"; h.i = h.i + 1000; h.f = h.f + 1000; } /* ---------------------------------------------- How to pass class variables by REFERENCE ---------------------------------------------- */ void Print2(myClass & h) { cout << "Structure values = (" << h.i << ", " << h.f << ")\n"; h.i = h.i + 1000; h.f = h.f + 1000; }