can anybody tell me the difference between structures in c and structures in
c++?
in C and C++ you can create composite data types with struct
-
struct Student {
-
char name[20]; // student name
-
int age; // student age
-
int course_code; // institutions course code
-
int course_year; // year of course
-
};
-
a struct can only contain data members.
In C++ the aggregate type class (an extension of the idea of struct) enables users to define their own types each of which is an encapsulation of:
(a) data members (fundamental types and derived types, e.g. arrays, structures, classes, etc.),
and (b) function and operator members which operate upon the data.