Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Difference between Class and Struct.

Answer Posted / kishore

What is the difference between class and structure?

1) Structure: Initially (in C) a structure was used to
bundle different type of data types together to perform a
particular functionality. But C++ extended the structure to
contain functions also. The major difference is that all
declarations inside a structure are by default public.

Class: Class is a successor of Structure. By default all
the members inside the class are private.

2) structures in c++ doesn't provide data hiding where as a
class provides data hiding

classes support polymorphism, whereas structures don't
3) class and structure are very similar. the former is
heavyweight while the latter is light weight. reference to
the former rests on the heap..while the latter in whole
(instance and data) rests on the stack. therefor care
should be taken not to make a struct very heavy else it
overloads the stack causing memory hogging. class needs to
have an instance explicitly created to be used. A struct
doesn't have to be explicitly initiated

Is This Answer Correct ?    44 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is void main used?

1035


Do you know what are bitwise shift operators in c programming?

1059


What are the 4 data types?

964


How to write a code for reverse of string without using string functions?

2074


What is bin sh c?

987


Tell me what is the purpose of 'register' keyword in c language?

969


Which is an example of a structural homology?

1246


general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only

1030


What is derived datatype in c?

1038


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

1070


What is main function in c?

1015


write a c program to find the sum of five entered numbers using an array named number

2076


What is int main () in c?

1028


What do you mean by Recursion Function?

1070


What is void main ()?

1012