What is the difference between Class and Structure?
Answers were Sorted based on User's Feedback
Answer / ravi kumar jain
The difference between a class and a structure is that, by
default, all of the members of a class are private and, by
default, all of the members of a structure are public.The
difference between a class and a structure is that, by
default, all of the members of a class are private and, by
default, all of the members of a structure are public.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / sharad
in c++ structure and class are same. we can use the
structure in place of class for creating the object. but
the difference is only the default access specifier of the
class is private and public of the structure.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / deepica
in classes we can declare variables and functions while in structure we can have only functions.In classes we have ACCESS SPECIFIER,while in structures we dont have any.Ic classes no Keyword is used ,while in Structures STRUCT keyword is used.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / nikhil jain
Structures are value types; classes are reference types.
Structures use stack allocation; classes use heap
allocation.
A structure must have at least one nonshared variable or
event member; a
class can be completely empty.
Is This Answer Correct ? | 4 Yes | 9 No |
Answer / hardik savani
The Structure ara used in c and c++
but class is used only in c++ and other opps languages
Is This Answer Correct ? | 23 Yes | 33 No |
Answer / anupam gupta
class has define object and funtion
structure has define only object
Is This Answer Correct ? | 8 Yes | 18 No |
Answer / shiva
we create an object for class.but not creating for structure
Is This Answer Correct ? | 3 Yes | 19 No |
Answer / arun
a structure is nothing but a structure.a class is nothing
but a class
Is This Answer Correct ? | 2 Yes | 26 No |
Answer / mm .mm
class can be used in other project ... but stucture can not
be used it's only present in the main
Is This Answer Correct ? | 20 Yes | 48 No |
Answer / rafat-+8801671123467
class is class and structure is structure.
Is This Answer Correct ? | 6 Yes | 36 No |
Is c++ double?
What is the difference between equal to (==) and assignment operator (=)?
write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1
What is conversion constructor?
If a function doesn’t return a value, how do you declare the function?
What is size of a empty class?
7 Answers Microsoft, Tata Elxsi, Wipro,
class X { private: int a; protected: X(){cout<<"X constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl} }; Referring to the code above, which one of the following statements regarding "X" is TRUE? a) X is an abstract class. b) Only subclasses of X may create X objects. c) Instances of X cannot be created. d) X objects can only be created using the default copy constructor. e) Only friends can create instances of X objects.
What is a v-table?
Which ide is best for c++?
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
How a modifier is similar to mutator?
What is a mutex and a critical section.Whats difference between them?How do each of them work?