Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 / eshetu

1. IN STRUCTURE THE DATA MEMBER BY DEFAULT IS PUBLIC BUT IN
CLASS THE DATA MEMBER ARE PRIVATE.
2. THE STRUCTURE ONLY CONTAIN DATA MEMBER BUT CLASS CONTAIN
DATA MEMBER & MEMBER FUNCTION.
3.IN STRUCTURE THE STRUCTURE NAME CAN'T STAND ALONE.BUT THE
CLASS NAME CAN STAND ALONE.

Is This Answer Correct ?    10 Yes 5 No

What is the difference between Class and Structure?..

Answer / liyakath ulla r

the structurs are used in both c and c++.
but class is used only in c++ and othe opps languages

Is This Answer Correct ?    67 Yes 63 No

What is the difference between Class and Structure?..

Answer / aashu gupta

There are only and only 2 differences between structure and class :
1. By default members are public in structures and private in class
2. Default inheritance in structure is public and private in class

you can verify the above differences by executing following code:
#include<iostream>

//code compiles and executes correctly means that //inheritance and polymorphism is allowed in structu
//res

using namespace std;

struct Base
{
int A;
virtual void display()=0; //polymorphism is allowed in structure
};

struct Derived:Base //public in struct and private in class
{
int B;
void display();
};

void Derived::display()
{
cout<<endl<<"A = "<<A<<endl;
}

int main()
{
Derived D;
D.A = 111;
D.display();
getchar();
return 0;
}

////////////////////////////////////////////////

Is This Answer Correct ?    5 Yes 1 No

What is the difference between Class and Structure?..

Answer / sudip das.

The difference between a CLASS and STRUCTURE are that:
1) CLASS are reference type where as STRUCTURE are value type.
2)By default,all of the members of a CLASS are private, but all of the members of a STRUCTURE are public.
3)CLASSES use heap but STRUCTURE use stuck.
4)CLASS members can be declared as protected but STRUCTURE members can not be.
5)CLASS contain data members and member function, but a STRUCTURE is contain only data member.

Is This Answer Correct ?    5 Yes 1 No

What is the difference between Class and Structure?..

Answer / vinod

The difference between a class and a structure is that, by
default, all of the members of a class are private and also private,public and protected but in structure by
default, all of the members of a structure are public.

Is This Answer Correct ?    5 Yes 3 No

What is the difference between Class and Structure?..

Answer / hardik savani

class is refrains type and structure is value type most op
us variable public and private in class.
public variable is use any component and private variable is use only class property

Is This Answer Correct ?    6 Yes 6 No

What is the difference between Class and Structure?..

Answer / pratiksha desarda

while creating variables of structure,it is compulsary to
write 'struct' keyword. and for creating object of class,
keyword 'class' is not necessary to write.

Is This Answer Correct ?    2 Yes 2 No

What is the difference between Class and Structure?..

Answer / guest

(1)Class Design For Object , Struct Design For Value Thus
Class is Refrence Type (Heape) but Struct is Value Type
(Stack) And Thus Struct is Faster Than Class ,

(2) Class is not Accessable Meanning We Can Access it By
Object , Struct is Accessable Meanning We Can Access it By
Value (Varible).

(3) Class Support Inheritance , Struct Not Support Inheritance .

(4)Class id Added Behavior (Methods) , Struct Not Added
Behavior

(5)Class Exist at higher Level of the Program , Struct Exist
at Lowest Level of the Program .

(6) A struct cannot declare a default constructor (a
constructor without parameters) or a destructor.Class Can .

(7)a small class may be more efficiently handled by the
system if you declare it as a struct instead.

Is This Answer Correct ?    2 Yes 2 No

What is the difference between Class and Structure?..

Answer / ramesh.alavala

class provides data hiding,structures doesn't provide.
class support polymorphism,structures doesn't support.
classes by default are inherited by privately,structures are
inherited by publicly.
classes can be abstract, structures can't be abstract.

Is This Answer Correct ?    3 Yes 3 No

What is the difference between Class and Structure?..

Answer / rohit patil

Syntax of class
class class_name
{
variable_declaration
function_declaration
};

syntax of structure
struct struc_name
{
variable declaration
};

Is This Answer Correct ?    2 Yes 2 No

Post New Answer



More C++ General Interview Questions

class HasStatic { static int I; }; Referring to the sample code above, what is the appropriate method of defining the member variable "I", and assigning it the value 10, outside of the class declaration? a) HasStatic I = 10; b) int static I = 10; c) static I(10); d) static I = 10; e) int HasStatic::I = 10;

1 Answers   Quark,


What are the extraction and insertion operators in c++?

0 Answers  


Explain what are accessor methods?

0 Answers  


Explain what is polymorphism in c++?

0 Answers  


If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3

0 Answers  






What are the general quetions are in DEna bank manager IT/System interviews?

0 Answers   Dena Bank, ICICI,


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

0 Answers  


What is the Difference between "vector" and "array"?

15 Answers   Covansys, Gambit, TCS, Wipro,


What is the difference between Char a[ ]=”string” and char *a=”String”

11 Answers   Adobe,


What are the implicit member functions of class?

0 Answers  


What is meaning of in c++?

0 Answers  


How can we check whether the contents of two structure variables are same or not?

0 Answers  






Categories