-
Junior Member
structure and class
What is difference between structure and class in C++
-
Junior Member
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
-
Expert Member
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
-
Forum Rules