My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
Paid Surveys
|
classes
Posted Date: 30 Apr 2008 Resource Type: Articles/Knowledge Sharing Category: Education
|
Posted By: mohit Member Level: Gold Rating: Points: 5
|
|
|
|
Classes
The declaration of a class adds a new type to C++ type system. A class is an encapsulation of variable and function declarations, called data members and function members respectively. Variables can have any type, , but they must have unique names within the scope of the class. Functions can have the same name, even within the scope, but must have different signatures (the functions can be overloaded). All members are subject to access control; the default is private, but any member can be made public by using an access control keyword within the body of the class declaration. Function members may be simply declared as prototypes, or defined within the class as inline functions. Function members may be defined externally. Special function members are constructors, and the destructor. Here is an example class declaration showing all these points:
class Eg { int i1; // a private data member of base type int C *c; // a private pointer to an object of type C public: Eg() { i1 = 0; c = 0; } // the (public) default // constructor,defined inline Eg(int ii) { i1 = i; } // an overloaded constructor ~Eg(); // the prototype for the // destructor void f1(int); // a prototype for a public // function member private: void f1(int, int); // a prototype for a // (private)overloaded function int f2() { cout << "f2" << endl; } // an inline private // function public: int i2; // a public data member float f3(int, float); // a prototype for a public function };
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
|