dcsimg
Rupesh kumar(M.C.A second year) Dept of computer science, university of pune
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rupesh_kumar
Posted On:   Sunday, January 2, 2005 02:38 AM


What is different between struct and class.

Re: Rupesh kumar(M.C.A second year) Dept of computer science, university of pune

Posted By:   Vikram_Kumar  
Posted On:   Monday, January 31, 2005 08:35 AM

A basic difference is that Struct's have 'public' member and class's have 'private' by default.

in C++ language point of view.

Re: Rupesh kumar(M.C.A second year) Dept of computer science, university of pune

Posted By:   Anonymous  
Posted On:   Wednesday, January 5, 2005 12:41 AM

In C struct is a construct that contains different variables, possibly of different types - like a compound variable.

In C++ it is the same but it can also have functions that operate on these variables. All variables and all methods are public. Thus in C++ struct is like a class where everything in public by default, unless you say otherwise.

In C++ class contains variables and method but everything is by default private and you can say otherwise.

In Java there is no struct.

In Java a class contains variables and methods that operate on the variables. By default everything has default access - meaning public for other classes in the same package and private elsewhere and - of course - you can say otherwise.

To say otherwise - in C++ and Java - use the keywords private, protected or public.

Re: Rupesh kumar(M.C.A second year) Dept of computer science, university of pune

Posted By:   WarnerJan_Veldhuis  
Posted On:   Monday, January 3, 2005 11:52 PM

When asking a question, the "subject" field should contain a small description about your problem, not your entire resume....

Re: Rupesh kumar(M.C.A second year) Dept of computer science, university of pune

Posted By:   Anonymous  
Posted On:   Monday, January 3, 2005 04:23 AM



Hi Rupesh:


The basic difference between Struct and class is:


Class: contains member variables and methods for holding bussiness logic.

Whereas struct conatains only member variables we can't define and implement methods inside struct.



Re: Rupesh kumar(M.C.A second year) Dept of computer science, university of pune

Posted By:   Simon_Ablett  
Posted On:   Sunday, January 2, 2005 06:47 AM

Leaving aside the fact that 'struct' is a C/C++ construct and not available in Java (this being a Java forum). Trying to remember back to my C++ days I would say that a 'struct' is a simple form of a 'class' in which all of its members are public.

Regards.
About | Sitemap | Contact