Forward declaration of a typedef in C++

user96825 picture user96825 · Apr 30, 2009 · Viewed 168.1k times · Source

Why won't the compiler let me forward declare a typedef?

Assuming it's impossible, what's the best practice for keeping my inclusion tree small?

Answer

Hong Jiang picture Hong Jiang · Apr 30, 2009

You can do forward typedef. But to do

typedef A B;

you must first forward declare A:

class A;

typedef A B;