0

I need a way to do the following and I cannot think of one, this is what I have so far:

typedef Obj2*(*Reaction)();
class Obj1
{
    public:
    Reaction reaction;
};
class Obj2
{
    public:
    unsigned int numobj1;
    Obj1 *objects;
};
class Obj3:Obj2
{};

Can you find any way of doing this within the syntactical rules of C++?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Labdabeta
0

Presumably you mean using Obj2 in the typedef despite it not being declared yet. You can forward declare the class to remove syntax errors:

class Obj2;
typedef Obj2*(*Reaction)();
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.