what is the main function of class in c++?when we have to use class ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anireddy
    New Member
    • Jan 2010
    • 1

    what is the main function of class in c++?when we have to use class ?

    will u explain more about the class
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Please start reading the OOP concept first. You will get a clear picture.
    Google and find more about classes..

    Regards
    Dheeraj Joshi

    Comment

    • newb16
      Contributor
      • Jul 2008
      • 687

      #3
      The main function of C++ class is being an implementation of 'object' paradigm of OOP. We _have_ to use it when usage of classes is required by external framework built upon classes itself.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        There are no classes in C++.

        All C++ has are structs.

        The C++ "class" is implemented as a struct.

        This:

        Code:
        struct MyStuff
        {
             private:
                 int data;
             public:
                 void SetData(int);
                 int   GetData();
                 ///etc...
        };
        is exactly the same as:

        Code:
        class MyStuff
        {
             private:
                 int data;
             public:
                 void SetData(int);
                 int   GetData();
                 ///etc...
        };
        That is, as long as you specify our member access as public/private/protected, there is no difference between a struct and a class.

        There is one difference when you do not specify the member access. The default access for a struct will be public whereas the default access for a class will be private.

        I suggest you expand your research into how to implement encapsulation.

        Comment

        Working...