What is the difference between class and structure?

Answers were Sorted based on User's Feedback



What is the difference between class and structure?..

Answer / guest

structure is a value type class is reference type,
struct Memory will be on stack and class Memory stored on
Heap,
struct not suports inheritance and class can?

Is This Answer Correct ?    18 Yes 2 No

What is the difference between class and structure?..

Answer / mohan

By default the members of struct are public.
By default the members of class are priavte.

When an object is created to a class, constructor will be
called automatically.
But not in struct (if structure having member function with
structure name)

Is This Answer Correct ?    15 Yes 0 No

What is the difference between class and structure?..

Answer / konankiswetha

class is a slow access because of heap memory. But struct
is a faster in access because of stack memory.



values are initialize at the time of declaration in class
but not in struct.

Is This Answer Correct ?    6 Yes 1 No

What is the difference between class and structure?..

Answer / arvind

The main difference is
Structure ... Class
struct . Class
{ . {
data members ... data members
} ... +
... Member functions
... }

We can't define Functions inside structure where as in class we can define inside

Is This Answer Correct ?    4 Yes 0 No

What is the difference between class and structure?..

Answer / chetan

struct initialize with keyword struct
class initialize with keyword class

Is This Answer Correct ?    2 Yes 0 No

What is the difference between class and structure?..

Answer / satish

1.class access data members and member functions but
structure access only data members
2.class supports constructor but structure does not supports.

Is This Answer Correct ?    2 Yes 1 No

What is the difference between class and structure?..

Answer / nandkumar

Class can be single tent.
but not in case of structure.

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More OOPS Interview Questions

Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

0 Answers   TCS,


What is destructor example?

0 Answers  


write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.

0 Answers   Microsoft, TCS,


how much classes are used in c++

5 Answers  


What is the difference between a mixin and inheritance?

0 Answers  






What are the advantanges of modularity

2 Answers  


What is abstraction example?

0 Answers  


what is use to destroy an object? illustrate.

5 Answers   TCS,


what are the different types of qualifier in java?

0 Answers   TCS,


what is Class in oops with example?

4 Answers   HCL,


why c++ is a highlevel language

3 Answers   Satyam, Tech Mahindra,


What is operator overloading? Give Example

11 Answers   CTS, IBM, TCS,


Categories