What is the difference between class and structure?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / chetan
struct initialize with keyword struct
class initialize with keyword class
| Is This Answer Correct ? | 2 Yes | 0 No |
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 |
Answer / nandkumar
Class can be single tent.
but not in case of structure.
| Is This Answer Correct ? | 0 Yes | 3 No |
WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE??
21 Answers Biocon, MIT, NIIT,
What Is a Polymorphism? How many types of polymorphism and whats that use in application?
What is abstraction in oop with example?
1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)
When is it necessary to use member-wise initialization list in C++?
How to call a non virtual function in the derived class by using base class pointer
Why do we use encapsulation in oops?
Please send ford technologies placement paper 2 my mail id
WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE
What is a linked list?
What is a friend function & its advantage?
advantage and disadvantage in c++>>oops and what are the questions ask for interview in c++>>oops. could you tell me or reply me