I have a nested class declared as:

class A
{
    class B
    {
         // members
    };

    // members
};

Is there a good way to avoid typing A::B every time I need to access B's members? I'd just like to do this in one .cpp file. I tried "using namespace A;" but I found out that class scopes and namespace scopes are not the same thing.

Recommended Answers

typedef A::B B ;

// ...
Jump to Post

All 3 Replies

You need to declare A as a namespace. Then you can put

using A::B;

once and just use the class name.

typedef A::B B ;

// ...
commented: thanks +2

Thanks, typedef was what I was looking for!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.