You are confused, or your example does not show what you are asking. In your code example, you are not trying to "forward the typedef declaration" (for example, this is not possible or useful, see below), you are trying to update the existing typedef name (i.e., an Alias for one type) as a completely different type.
You already said that K is a typedef for A , then you say it is a class K Think about it. It cannot be both class A and class K Both that, and another (1) and (2) do not work for the same reason.
Looking through these lines of the example:
class A;
Still.
struct A;
I don’t know why you said "C ++ 11" here, it is normal in C ++ 03. Classes and structures are the same in C ++. They are "object types" and "class types." For a direct declaration, the class key (i.e., struct or class ) is interchangeable.
class K;
K declared as typedef for class A , the name cannot be reused to declare a new type in the same scope.
[In addition, C resolves the following because structure names and typedef names are in different namespaces:
struct A { }; typedef struct AK;
But now there are two different types, called struct K and K , that are not related to each other. Doing this would be confusing and rather stupid.]
But from your comments, perhaps this is not what you are actually trying to do anyway.
Based on your comments, maybe your broken examples are misleading and what you really want to do:
typedef class AK; // forward declare A as class and declare K as typedef for it
This declares a typedef for a type that is not yet defined.
It would be useless to send-declare typedef, you could not do anything about it, because you would not know what type it was typedef, and you can do very little in C ++ without knowing something of type. Not knowing if this is an object type, a link type, or a function type, what you can really do is declare another typedef for it!
Consider:
typedef K;
I think you say you want this to be true, so do you expect this to work?
K* k = f(); g(k);
That should work, right? You don't need to know type K because you only pass it to pointers, right? Wrong. What if you later define K as follows:
typedef int& K;
Now f has a signature int&* f() , which is invalid. You should know what typedef is for typedef, so its declaration should state that it is not just forward-declaring it as a name.