typedef std::list<LDAPCtrl> CtrlList;
typedef CtrlList::const_iterator const_iterator;

please help me in understanding the above typedef statements as we know that typedef syntax is,
typedef <attributes> datatype aliasname


7 Years
Discussion Span
Last Post by ermithun

Typedef's are likely to be a lot related with Macro's,
Though there is a huge difference between Macro's and Typedef's

Macro's follow a " find and replace " mechanism before the code is actually compiled.

Typedef's almost do the same thing but instead of find and replace, they are much like a "ALIAS" or "A.K.A"
Basically they give another name to a pre-existing statement.

typedef std::list<LDAPCtrl> CtrlList;

This first typedef specifies the compiler to give std::list<LDAPCtrl> a name of CtrlList So the next time you declare a CtrlList ,

CtrlList biglist;

is equivallent to

std::list<LDAPCtrl> biglist

So That way we do-not need to specify everything again.

Now lets consider the second statement.

typedef CtrlList::const_iterator const_iterator;

Now we specify that CtrlLIST::const_iterator which is again equivallent to std::list<LDAPCtrl>::const_iterator to be accessible by just a simple name of const_iterator

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.