the use of the :: operator

J

jimjim

Hello All,

Assume:

class AnObjectType{
typedef std::list <AnotherObjectType> Collection;
typedef SmartIterator <Collection> Iterator;
Iterator get( void);
Collection mCollection;
}

AnObjectType::Iterator AnObjectType::get( ){ //does Iterator need to be
qualified (AnObjectType::) here, and why?
Collection::iterator scit ;
return AnObjectType::Iterator(mServiceCollection); //does Iterator need
to be qualified here, and why?
}

TIA
 
V

Victor Bazarov

jimjim said:
Assume:

class AnObjectType{
typedef std::list <AnotherObjectType> Collection;
typedef SmartIterator <Collection> Iterator;
Iterator get( void);
Collection mCollection;
}
;
AnObjectType::Iterator AnObjectType::get( ){ //does Iterator need to
be qualified (AnObjectType::) here, and why?

Yes, it does.
Collection::iterator scit ;
return AnObjectType::Iterator(mServiceCollection); //does Iterator
need to be qualified here, and why?

No, it does not.

The rest of the homework you need to do yourself. Find a good book
and read the explanation of the rules for "name lookup".

V
 

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

No members online now.

Forum statistics

Threads
473,800
Messages
2,569,657
Members
45,417
Latest member
BonitaNile
Top