-7

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.

enb081
  • 3,831
  • 11
  • 43
  • 66
Zdenek Hatak
  • 1,135
  • 14
  • 23
  • 1
    Please post the real code with real error messages you are getting. – Naveen Jun 11 '13 at 07:00
  • 7
    "but unfortunately I don't have time to deal with this" - erm what? – Mitch Wheat Jun 11 '13 at 07:01
  • It's a school project and the dead-line is near. I am sorry if I put this in some kind of a rude way. – Zdenek Hatak Jun 11 '13 at 07:04
  • The only error I get is "error: ‘B’ does not name a type" – Zdenek Hatak Jun 11 '13 at 07:05
  • 1
    If the dead-line is near, spend every minute to solve it yourself! Or did you wasted long time and find yourself cornered? ... Anyway, if you want a solution, we will need to see the minimal program which reproduces your problem. It's hard to suggest something while walking in the dark. – CygnusX1 Jun 11 '13 at 07:06
  • Exactly. I wasted a kind of huge amount of time looking for a solution. Those two I mentioned are the only ones I came up with. – Zdenek Hatak Jun 11 '13 at 07:09
  • Here is the code: http://pastebin.com/b6xBVTaV (line 55 is where the problem is). – Zdenek Hatak Jun 11 '13 at 07:14
  • 1
    Time looking for a solution is not a wasted time. You gain a lot of experience and you will find the solution to the next problem faster. By "wasted time" I meant not actually doing anything... – CygnusX1 Jun 11 '13 at 14:53

1 Answers1

1

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 );
}
greatwolf
  • 20,287
  • 13
  • 71
  • 105
  • This project is starting to annoy me. Thank you. I don't understand how could I miss this. – Zdenek Hatak Jun 11 '13 at 07:48
  • 1
    Unless it's a project requirement, you can consider using `operator()` instead that takes 2 parameters `x, y`. This way you can avoid the proxy class altogether. It might help simplify things. – greatwolf Jun 11 '13 at 07:51