what is the difference between class and structure in C++?
Answers were Sorted based on User's Feedback
class members have the privite access by default where as
structure members have the public access by default
Is This Answer Correct ? | 34 Yes | 2 No |
Answer / murali
A class is inhertied to onther class but structure we
cannot inhertied
Is This Answer Correct ? | 18 Yes | 8 No |
Answer / balaram singh
1->CLASS IS THE ADT WHERE AS STRUCTURE IS UDT
2->CLASS NEEDS ACCESS SPECIFIER SUCH AS PRIVATE,PUBLIC &
PRIVATE WHERE AS STRUCTURE MEMBERS CAN BE ACCESSED BY
PUBLIC BY DEFAULT & DO'NT NEED ANY ACCESIFIERS.
3->CLAAS IS OOPS WHERE STRUCTURE IS BORROWED FROM
TRADITIONAL STRUCTURED(POP) CONCEPT
Is This Answer Correct ? | 13 Yes | 4 No |
Answer / navneet kaur
c is a procedure oriented language but c++ is a object
oriented language.
Is This Answer Correct ? | 6 Yes | 3 No |
Answer / vijayendra singh chand
The main difference between class and structure is that
class is reference type whereas structure is value type.
Is This Answer Correct ? | 5 Yes | 4 No |
Answer / naveen tuteja
A structure can't contain the static ans constant variable
but a class can contain both.
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / naveen tuteja
We can declare a structure without a name tag but we cannot
declare a class without name tag.
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / renuka
IN CLASS WE USE BOTH VARIABLE AND FUNCTION OR IN STRUCTURE WE USE VARIABLE ONLY....
Is This Answer Correct ? | 3 Yes | 3 No |
Answer / kanak shah
there is vast differece between class and structure in c++
in my view class is class room and structure mean class
room structure.
Is This Answer Correct ? | 3 Yes | 28 No |
How is polymorphism achieved?
wht is major diff b/w c and c++?
Why a "operator=(...)" when there is a copy ctor?
In multiple inheritance , to create sub class object , is there need to create objects for its superclasses??? in java and c++ both. Actually i have some information that is , all available members from its superclasses , memory created in subclass obj , so no need to create object for its superclasses...??? Thanks in Advance
What is the purpose of polymorphism?
for example A,B,C,D are class all the 4 class contain one method who() but the method who() implementaion is differnet among each class. the relation among the 4 class are A is base class and is inherited by B and C.and from this two B and C where D is inherited. the question is i want to display the output who() method in all the classes(A,B,C,D)the output of who() method is diferrent amond all the class(A,B,C,D) ------A------ virtuval who(print a) override | | who(print b) B C override who(print c) | | -------D------ override who(print d)
How do you answer polymorphism?
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What is class in oop with example?
What is multilevel inheritance in oop?
#include <iostream> using namespace std; int main() { int a = 2; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][c[1][4]]; }
We have a scale and 7 balls. 1 ball is heavier than all the rest. How to determine the heaviest ball with only 3 possible weighing attempts?