girish
Answered On : Jul 5th, 2005
structure member are public in default and class members are privare in default.

1 User has rated as useful.
Login to rate this answer.
Sharath
Answered On : Mar 20th, 2006
1:By default,the members of structures are public while that for class is private
2: strutures doesn't provide something like data hiding which is provided by the classes
3: structures contains only data while class bind both data and member functions
Login to rate this answer.
sunil yadav
Answered On : Nov 17th, 2006
Structure dosen't support the polymorphism, inheritance and initilization.
In a Structure all the data types are public but in class they are private.
In a Structure we can't initilse the value to the variable but in class variable we assign the values.
Structuer is a collection of the different data type.
Login to rate this answer.
Gagan
Answered On : Feb 5th, 2007
There should be no confusions. The only difference between a structure and a class is that all members in a class are private by default whereas they are public in a structure.

2 Users have rated as useful.
Login to rate this answer.
Arun
Answered On : Jul 16th, 2007
Try inheritance, polymorphism, overloading, encapsulation, etc.
all these are possible.........
1. struct data is public by default.. but its private in a class
2. class is successor of struct in heirarchy..
3. struct is ovrloaded.. in C++ its not same with class..
Login to rate this answer.
Structure does support inheritance.
try out the following code.
#include
using namespace std;
struct Base
{
int A;
};
struct Derived:public Base
{
int B;
void display();
};
void Derived::display()
{
cout<<endl<<"A = "<<A<<endl;
}
int main()
{
Derived D;
D.A = 111;
D.display();
getchar();
return 0;
}
Try out private and protected inheritance as well. It works. :)
Regards,
Sumit

2 Users have rated as useful.
Login to rate this answer.
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
struct a
{
protected:
int x;
public:
a(int y)
{
x=y;
}
void showdata()
{
cout<<"x="<<x;
}
};
void main()
{
a aa(2);
aa.showdata();
getch();
}
structure support inheritance in cpp

1 User has rated as useful.
Login to rate this answer.
Similar to difference in default access specifier, default inheritance too is different in Class Vs Structures.
Login to rate this answer.
A structure and a Class in C++ are same in every aspect expect in structure by default data members and member functions are public and private in case of class.

1 User has rated as useful.
Login to rate this answer.
Structure is the ancestor of the class and the difference lies in the fact that all the members inside the class are taken as private by default but in structure all the members are made as public by default.
Login to rate this answer.
By default structure is private and class is public.
Login to rate this answer.
You cannot use inline functions in a structure

1 User has rated as useful.
Login to rate this answer.
In case of class by default members and methods are in private section and In case of structure they are in public section.
Login to rate this answer.
Struct cannot be inherited.. thats the thing to be remembered.
Login to rate this answer.
Class stores both variables and methods.
Structure stores only members(variable) of different datatype.
By default the access specifiers of class are private but where as in structure it is public.
Login to rate this answer.
yogish
Answered On : Aug 5th, 2011
structure support multiple inheritence also try this code
Code
struct stud1
{
int x;
float y;
stud1(int x,float y)
{
this->x = x;
this->y = y;
}
};
struct stud2:public stud1
{
char c;
stud2(int x,float y,char c):stud1(x,y)
{
this->c = c;
}
};
struct stud3:public stud2
{
char d;
stud3(int x,float y,char c,char d):stud2(x,y,c)
{
this->d = d;
}
};
int main()
{
stud3 struTest(1,2.5,'y','x');
cout<<struTest.x<<"
"<<struTest.y<<"
"<<struTest.c<<"
"<<struTest.d<<endl;
getchar();
return 0;
}
Login to rate this answer.
prasad
Answered On : Dec 27th, 2012
inline can be used in structures ...it is possible to work
Login to rate this answer.