Results 1 to 3 of 3

Thread: structure and class

  1. #1

    structure and class

    What is difference between structure and class in C++


  2. #2
    Junior Member
    Join Date
    Nov 2007
    Answers
    9

    Re: structure and class

    Hi!

    Main difference between STRUCTURE and CLASS are follow:

    STRUCTURE:

    ------------> The Structure is a collection of dissimilar data types
    ------------> By default the structure variables are PUBLIC
    @ The structure have not an Encapsulation feature.
    i.e We can access data anywhere in it's Scope (global or local etc).
    @ We can't Initialize variables (structure contained data variables) within structure

    CLASS:

    ----------> The CLASS is also a collection of dissimilar data types as well as ENCAPSULATION feature.
    ----------> By default the CLASS variables are PRIVATE.
    @ Encapsulation means that the member data as well as member functions are hiding from external access.
    i.e Only you can access member data by it's OBJECT (It's nothing but, CLASS VARIABLE) depends on
    declaration of variables(member data) either PUBLIC or PRIVATE or PROTECTED.
    @ We can initialize variables(data members) within CLASS by using INLINE function.
    @ CLASS have some speciality as the INHERITANCE , POLYMORPHISM , OVERLOADING etc.

    ------>main difference
    @some other difference



    Regards
    Venkat.G


  3. #3
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: structure and class

    The C++ class is an extension of the C language structure. Because the only difference between a structure and a class is that structure members have public access by default and class members have private access by default, you can use the keywords class or struct to define equivalent classes.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact