C++ examples for Class:Class Creation
Defining a object with a C++ class
#include <cstdlib> #include <iostream> using namespace std; class MyClass /*from w ww. j a va 2 s . c o m*/ { public : int i; float f; }; int main(int argc, char *argv []) { MyClass anObject; anObject .i = 10; anObject .f = 3.14159; cout << "i = " << anObject .i << endl; cout << "f = " << anObject .f << endl; return (0); }