Forward declaration of nested types/classes in C++

I recently got stuck in a situation like this: class A { public: typedef struct/class {…} B; … C::D *someField; } class C { public: typedef struct/class {…} D; … A::B *someField; } Usually you can declare a class name: class A; But you can’t forward declare a nested type, the following causes compilation error. … Read more

Is it possible to forward-declare a function in Python?

Is it possible to forward-declare a function in Python? I want to sort a list using my own cmp function before it is declared. print “\n”.join([str(bla) for bla in sorted(mylist, cmp = cmp_configs)]) I’ve organized my code to put the definition of cmp_configs method after the invocation. It fails with this error: NameError: name ‘cmp_configs’ … Read more

What are forward declarations in C++?

At: http://www.learncpp.com/cpp-tutorial/19-header-files/ The following is mentioned: add.cpp: int add(int x, int y) { return x + y; } main.cpp: #include <iostream> int add(int x, int y); // forward declaration using function prototype int main() { using namespace std; cout << “The sum of 3 and 4 is ” << add(3, 4) << endl; return 0; … Read more