Declaring a variable with “class ” keyword vs Declaring one without “class” keyword in function signatures

后端 未结 4 987
抹茶落季
抹茶落季 2021-01-12 18:58

What is the difference between the two methods?

Sometimes when I get compile-time errors complaining that the compiler does not recognize some class types in functi

4条回答
  •  既然无缘
    2021-01-12 19:48

    The compiler must know the type of the function parameter. Since you obviously don't provide a definition for example by including the header of Client you have to provide a forward declaration. That is what you do in the second example (in an unusual way), so the compiler knows, that Client is a class. Since you only use a Pointer, the declaration is enough and you don't need the definition at this point.

提交回复
热议问题