// class_a.h
#include "typedefs.h"
namespace MyProject
{
class A
{
// some constructors, functions, variables, etc. for A
class B
{
p_type_simple_function arr_fun [];
// error: static <error-type> MyProject::A::B::arr_fun[] array of functions is not allowed
}
}
}
Adding the typedef just prior to the declaration fixes the issue, so it seems to be some scoping/namespace problem that I just can't figure out:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// class_a.h
namespace MyProject
{
class A
{
// some constructors, functions, variables, etc. for A
class B
{
typedefvoid (A::B::*p_type_simple_function)();
p_type_simple_function arr_fun [];
// the above works fine
}
}
}
(I've written this code for the sake of this forum post so please don't mind the typos if any)
// class_a.h
#include "typedefs.h"
namespace MyProject
{
class A
{
// some constructors, functions, variables, etc. for A
class B
{
p_type_simple_function arr_fun [];
// error: static <error-type> MyProject::A::B::arr_fun[] array of functions is not allowed
}
}
}
This shouldn't even compile, let alone give you: "error: static <error-type> MyProject::A::B::arr_fun[] array of functions is not allowed".
Because the declaration of "MyProject::p_type_simple_function" appears before the declaration of both "A" and "B", the compiler should complain about "A" and "B" not being declared.
When "p_type_simple_function" is declared inside of "B's" scope, the compiler knows that both "A" and "B" exists, which is why your third code snippet compiles.