1

I have some functors that I want to make member variables of a class, which I declare in my header file like so

class A {
public:
//...
typedef struct functor1 functor1;
//...
}

I then want to define these functors in my source file (purely for organisational reasons), something like

A::functor1 {
     void operator()(int in) const {
     //stuff
     }
};

However this gives me an 'unqualified-id before ‘{’ token' error. Can anyone show me how to achieve what I'm aiming for or something similar?

Madden
  • 1,024
  • 1
  • 9
  • 27
  • 1
    You can't create variables with just a declaration. – R Sahu Apr 06 '16 at 15:37
  • 1
    Is [this](http://stackoverflow.com/a/2600679/4342498) what you are looking for? – NathanOliver Apr 06 '16 at 16:09
  • Funnily enough I was actually trying to get away from hiding the functors in a private namespace. I've settled on just leaving them in there and writing some accessors – Madden Apr 06 '16 at 16:47

0 Answers0