Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to access a typedef declared within a class declaration?

Tags:

c++

typedef

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?

like image 375
Earlz Avatar asked Dec 04 '25 13:12

Earlz


2 Answers

You can do it if the typedef is public

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

foo::barContainer
like image 142
NathanOliver Avatar answered Dec 08 '25 18:12

NathanOliver


 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;
like image 38
Marcus Müller Avatar answered Dec 08 '25 18:12

Marcus Müller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!