What?

Started by
18 comments, last by Wachar 21 years, 11 months ago
quote:Original post by granat
I suppose a signed int is just a special case of an unsigned int but still it is NOT the same thing although similar.

Nope, an unsigned int is a signed int constrained to the natural numbers (ie, the set of natural numbers is a subset of the set of integers, which is a subset of the set of real numbers). Theoretically speaking, of course.

However, a struct is a class in C++. The differences are public rather than private default access specification and public rather than private default inheritance. You can have virtual functions, inherit from the suckers and so on and so forth.

quote:
We might have been over this several times but did everyone agree on the subject ?

Loser. Loo-hoo-hoo-hoo-ser-eeerr!

Seriously, though, this isn''t a question of opinion; it''s a statement of fact. Feel free to disagree. At least the next time you get a roasting on this issue I can smirk and say "I told you so".

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!
Advertisement
quote:Original post by Oluseyi
Howewer, a struct is a class in C++. The differences are public rather than private default access specification and public rather than private default inheritance.


Hmm..Sounds like they are SIMILAR

-------------Ban KalvinB !
Consider this.

A panther is just a black leopard (I've heard that's the only difference). If I'm wrong about this I'm sure I can think of another example.

Would you say that a panther IS a leopard ? I would not. I would say that they are very similar. But there is a reason they have been given two seperate words.
If you say that a panther IS a leopard then we probably agree in reality but just not on definition.
I say if there is the slightest difference then it is not the same.

End of anal



[edited by - granat on April 29, 2002 4:24:25 AM]
-------------Ban KalvinB !
quote:ISO/IEC 14882: Programming Languages - C++
A structure is a class defined with the class-key struct; its members and base classes are public by default. A union is a class defined with the class-key union; its members are public by default and it holds only one data member at a time.

Please feel free to argue with the Standard committee. If it helps, you may draw up whatever inappropriate analogies help you to feel better about being wrong.

[C++ FAQ Lite | ACCU | Boost | Python]
I wouldn''t want to disagree with the Emperial Standard Committee.

I still say it''s a matter of definition but it''s not like it matters....



-------------Ban KalvinB !
Thanks for the lecture Oluseyi!
I appreciate you being very active, it helps a lot.

However, I agree and don''t agree on what you are saying. Ok, structs are kind of classes with all public members.

However, there is a difference between classes and structs, hence, structs are not classes. Closely related, but not identical. Knitty gritty details, but I wont consider them the same

Didn''t know that C/C++ defaults return types to int which by the way explains why the compiler did not complain above. So, I''ll change my advice: functions should have a return type - don''t depend on the default values, it might be implemented differently between compilers.

The rest is just something I add to my small pile of knowledge.

Why make it simple when you can make it sooo nice and complicated?
quote:Original post by clabinsky

So, I''ll change my advice: functions should have a return type - don''t depend on the default values, it might be implemented differently between compilers.


Those were constructors, they don''t have a return type.
quote:Original post by clabinsky
However, there is a difference between classes and structs, hence, structs are not classes.

Let''s try again. A struct *is a* class. Just because it has different default access does not make it a different thing. You can consider a struct as a specialisation of a class if it makes you happier, but it is still a class.
quote:
Didn''t know that C/C++ defaults return types to int which by the way explains why the compiler did not complain above.

Yes, but this is strictly illegal. Explicit return types should be returned, but most compilers will default to int if omitted.


[C++ FAQ Lite | ACCU | Boost | Python]
quote:Original post by clabinsky
However, I agree and don''t agree on what you are saying. Ok, structs are kind of classes with all public members.

However, there is a difference between classes and structs, hence, structs are not classes. Closely related, but not identical. Knitty gritty details, but I wont consider them the same

You would so fail a test on inheritance.
class Base{  // yatta};class Derived : public Base{  // yatta}; 

Is Derived a Base? Same with class and struct, and class and union.

Nuff said.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!
Silly me! I can''t believe I forgot about the : in the construcors(to set variables)! Also about the :: for the scope. Sorry Oluseyi and everyone else who had to put up with this! I promise I won''t post anything of this sort unless I''m in desperate need of it! Thanks again!

Take it to the Xtreme!

Wachar's Eternity <-<-<-<-<- Me own site!

This topic is closed to new replies.

Advertisement