Search code examples
c++classsyntaxproxy-classes

Proxy class and correct syntax c++


Let's say we got class A and method B... The correct Syntax is return type A::B() {...}

Now imagine, we have a class B inside the class A and plus method C that has the inner class B (proxy class due to [ ][ ] operator) as a "return type". How do I do that?

A::B A::B::C() {} does not work neither does B A::B::C() {}

Plus I'd like to have it in .cpp and .h file.


Solution

  • It looks like you're referring to the wrong scope for your operator[]. Perhaps you meant:

    CScreen::Proxy CScreen::operator[] (int index) const 
    {
      return Proxy ( m_playground, index, m_y );
    }