Earlz
Earlz

Reputation: 63825

Possible to access a typedef declared within a class declaration?

I'm writing a program in C++ and an external header file I'm using makes very liberal use of typedefs within class declarations.

So, when I go to lookup the return type of a function, I'll see GlobalVariableList FooBar(), but then to actually store the type it returns, I can't just use GlobalVariableType because its a typedef of iplist<GlobalVariabl> declared within the class I'm referencing in the header file.

Is it possible access a class's typedef declared within it at all from outside of the class?

Upvotes: 2

Views: 2945

Answers (2)

Marcus M&#252;ller
Marcus M&#252;ller

Reputation: 36347

 classname::typedefname

should work like a charm; GNU Radio does this all over the place:

basic_block

basic_block::basic_block(const std::string &name,
    io_signature::sptr input_signature,
    io_signature::sptr output_signature)

io_signature

typedef boost::shared_ptr<io_signature> sptr;

Upvotes: 2

NathanOliver
NathanOliver

Reputation: 180500

You can do it if the typedef is public

class foo
{
public:
    typedef std::vector<bar> barContainer;
//...
}

foo::barContainer

Upvotes: 8

Related Questions