Differences between C and C++

N

Nobody

I don't think I used 'class' or 'friend';
Of course all of these were or could have been fixed easily and with
negligible impact, consistent with your main argument.

Variable names tend to be private and are easy enough to rename. It's a
bit more problematic for a structure field which is part of a public API.
Possibly the best-known example is X11's XVisualInfo structure, which has
a field named "class" for the visual class (PseudoColor, TrueColor, etc).

By the time C++ became an issue, it was too well established to simply
change, resulting in:

typedef struct {
Visual *visual;
VisualID visualid;
int screen;
int depth;
#if defined(__cplusplus) || defined(c_plusplus)
int c_class; /* C++ */
#else
int class;
#endif
unsigned long red_mask;
unsigned long green_mask;
unsigned long blue_mask;
int colormap_size;
int bits_per_rgb;
} XVisualInfo;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top