#include class myClass { public: int i; float f; }; myClass x; // How to define struct variables int main(int argc, char *argv[]) { void f1(myClass); // pass struct by VALUE void f2(myClass &); // pass struct by REFERENCE x.i = 1234; // How to use a struct variable x.f = 3.14; cout << "initially: x = " << x.i << " " << x.f << endl << endl; f1(x); cout << "after f1(x): x = " << x.i << " " << x.f << endl << endl; f2(x); cout << "after f2(x): x = " << x.i << " " << x.f << endl << endl; } /* ---------------------------------------------- How to pass structure by VALUE ---------------------------------------------- */ void f1(myClass h) { h.i = h.i + 1000; h.f = h.f + 1000; } /* ---------------------------------------------- How to pass structure by REFERENCE ---------------------------------------------- */ void f2(myClass & h) { h.i = h.i + 1000; h.f = h.f + 1000; }