Advertisement

Is this the same .... ?

Started by February 18, 2004 03:46 PM
4 comments, last by Tree Penguin 21 years ago
class CName { // .... }NAME; and class CName { // .... }; typedef CName NAME; So, is the first example just an initial typedef? Thanks!
quote:
Original post by Tree Penguin
So, is the first example just an initial typedef?



I''m not qualified to give you a technical answer, but essentially the effect is the same. That is, typedef''ing your class into a new type will not change its properties in anyway. typedef is merely a friendly (read: non-evil) macro substitution in most cases. That is, while:

#define My_yesIgaveitasickoname_class mscclass My_yesIgaveitasickoname_class { };


is evil,

class My_yesIgaveitasickoname_class { };typedef My_yesIgaveitasickoname_class msc;


is not. If you want a technical explanation, have this thread moved to a more relevant forum, such as General Programming.



"Finishing in second place, simply means you are the first loser." - PouyaCat

"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
No.
Thanks, i now know what i wanted to know, no need for replacing.

EDIT: AP, what did you mean by no ?

[edited by - Tree Penguin on February 18, 2004 5:14:44 PM]
Actually, no I believe Crispy is wrong, or misread something. I tested it to make sure. The first example you gave will create an instance of CName, called NAME. It is not a typedef. If you had this:
typdef class CName {// ...} NAME, TypedefName2, AnotherTypedef /*...*/; 
then it would be a typedef (well, multiple typedefs, in that case). But
class CName {// ...} NAME, Name2, Object /*...*/; 
willl create objects, not typedefs.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
Ok, thanks !

This topic is closed to new replies.

Advertisement