3 ms·
the question is why does a struct exist at all. just because they could pass an exam is not a great indicator of understanding. if your students put member func
by throwawayaway 12y ago
the question is why does a struct exist at all. just because they could pass an exam is not a great indicator of understanding. if your students put member functions, virtual functions or inheritance into a struct i wonder what mental gymnastics you would engage to explain why they shouldn't do that without using C to do so.
it's like having a debate with the iraqi information minister, you don't even believe yourself what you are saying.
C# and D are sufficiently different, D and C# will not compile most/any C programs.
as soon as any of your students got in to a professional context and have to use C++ in anger, they found out pretty quickly that they actually didn't understand it. you did them a disservice by ignoring C.
the design decisions in C++ are reactions to C - not computer hardware, architecture or assembly. there are a few exceptions to this, but they are small in number.
the "why" is staring you in the face and you are willingly ignoring it. it's actually infuriating to try and learn from someone with this attitude, never explaining why correctly but giving directions with no explanation or falsified explanation.
- pjmlp 12y agoEverything from C++ can be discussed in the context of C++, there is no need to refer to other languages. A struct is a C++ data type that offers the same set of features as a class, just with a public access as default. The use cases for a struct are POD (Plain Old Data) used to aggregate variables that refer to a common data structure, hence struct as abbreviation. > C# and D are sufficiently different, D and C# will not compile most/any C programs. But they also have struct. So you don't need to explain struct to those developers? You can also do memcopy and pointer manipulations in C# and D. Why shouldn't then they also learn about C? Regarding the C subset in C++, it is actually C89 with a few semantic changes. There quite a few examples of C89 compliant code that won't compile with a C++ compiler or will have strange behaviors. The way struct namespaces work is such example.
- throwawayaway 12y ago>Use struts when you just need a data container. Use classes when you need to add behaviour. Simple rule, > A struct is a C++ data type that offers the same set of features as a class, just with a public access as default. these are lies. at this point it's a semantic argument, what you mean by "understand" is "use". what i mean by understand is its dictionary meaning. to answer your questions, no you don't need to explain them or teach C to them because the syntax for struct in those languages is not identical to C. that is why. because they are not C structs. "C++ structs" are C structs with some syntatic sugar applied. C structs will not compile in those languages. C structs are not valid code in those languages. I am aware of the long list of minor incompatibilities between C89 and C++, and how C++11 has removed some and added more In short you know nothing about this I don't already know and you are quite happy to knowingly deceive your students. i object but there's no point in debating with you further.