Bryan wrote:
I was looking through some old legacy code that has been a pain for some
time and I found this:
typedef struct MSObject {
// Members
} MSObject;
Why would you do this? And furthermore, why, if I change it to:
class MSObject {
public:
// Members
};
do all the functions that use MSObject complain of a syntax error ')'
when I try to compile?
I would really like to replace this typedef'ed type with an object
without having to modify all the files (and there are a bunch) that use it.
The original code with that typedef business was likely written to be
compatible with C or was written by someone unfamiliar with C++'s
changes. The first "MSObject" is the struct tag, and the second is a
the typedef name (i.e., an alias for "struct MSObject"). In C++, the
"typedef" and second "MSObject" are unnecessary, but even without them,
it can still be used as either "struct MSObject" or just "MSObject".
As for your syntax error, post a *complete* but *minimal* sample that
demonstrates the problem, and we can tell you.
Cheers! --M