Salt_Peter posted:
I disagree, a struct in C and a struct in C++ have absolutely nothing in
common, including terminology.
I think struct's original purpose was to store more than one value, e.g.:
struct EmployeeInfo {
unsigned long id;
char name[35];
unsigned hourly_wage;
};
C and C++ definitely have this in common.
However, C++ then brought in the concept of putting functions in with the
members, and called it a class:
class EmployeeInfo {
public:
unsigned long id;
char name[35];
unsigned hourly_wage;
unsigned CalculatePay( unsigned const hours_worked )
{
return hourly_wage * hours_worked;
}
};
This functionality was also extended to "struct"... in fact, they went
the whole hog and said that a "class" and "struct" are the same thing
(except of course for default access).
If you do C, you do C, period.
Not really. I've really only ever been a C++ programmer, but if you told
me I had to write a C program, I bet I could do it.
-Tomás