Difference between class and structure

This question is related to TCS Interview

Showing Answers 1 - 22 of 22 Answers

laxmikanth

  • Feb 10th, 2006
 

ans for this question is simple and it is:

There is no much difference between a class and a structure and the slight difference is the default scope of class is private where as the default scope of structure is global.

Nilesh Korpe

  • May 18th, 2006
 

Constructor is called in class where as there is no custructor for structor.

harsha

  • Jul 29th, 2006
 

a>the data members of a class are private by default where as those in structure are public.b>class can have the destructors while the structures cannot have.

  Was this answer useful?  Yes

pavankishore

  • Nov 28th, 2006
 

class is a user defined data type in object oriented paradigm.

it consists of both data and code(methods).

where as structure is also a userdefined datatype but consists of only data members.not methods

  Was this answer useful?  Yes

swathi

  • Dec 10th, 2006
 

 

         Structures allows organisation of data whereas class allows both organisation of data and data security.

  Was this answer useful?  Yes

winny gupta

  • Feb 15th, 2007
 

Firstly, a class is not declared in C.Secondly, in C++, the main difference is all the data members and member functions in classes are private by default whereas for structure they are public.

  Was this answer useful?  Yes

Uttam

  • Mar 4th, 2007
 

In C++ thr is no difference in class and structure except that  in class by default scope is private but in structure its public...other than that no other difference.

  Was this answer useful?  Yes

lotus08

  • Jun 27th, 2008
 

structure is a collection of data and class is a collection of data and functions.by defalut struct is public whereas class is private

  Was this answer useful?  Yes

We can list as:

1. In classes the default scope is private whereas in structures u have public.equir

2.Also, u can define the scope according to is requiremeuctunts in claasses.

3. In classes u can create fn nd methods which is not so in d case of structures.

4.You cn also do operator overloading in case of classes which is not so in d case of structures.

5.Various other object - oriented features are found in classes and not in structures wherin u can create objects which is not possible in structures.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions