classes and structs =================== A class is a logical method to organize data and functions in a same structure They are declared using keyword class, whose functionality is similar to the one of the C keyword struct, but with the posibility of including functions as members, moreover than only data. ex: class class_name { private: member; public: member; } object_name; where class_name is the name for the class(user defined type) and the optional field object name is 1, or several valid object indetifiers, the body of declaration can contain members that can be either data or function declarations and optional permission lables that can be any of these 3 keywords 1. private 2. public 3. protective private members: of a class are accessable only from other members of its same class or from its friend class protective members: are accessable in addition from members of the same class and friend classes public members: are accessable from anywhere where the class is visable ----------------------------------------------- #include class crectangle { int x, y; //data member public: void set_values (int, int); //member function int area (void) { return (x*y); } }; void crectangle::set_values(int a, int b) /*::scope operator, specify the class to which the member being declared belongs to. this is also an assignment.*/ { x=a; y=b; } int main() { crectangle rect;// declares rect as an object rect.set_values(3,4);// assigns values to rect cout <<"Area :"<< rect.area() << endl;// outputs result return 0; }