0

In class A, I have defined a type, namely A_T:

typedef int A_T;

In class B, I have defined another type, namely B_T:

typedef double B_T;

What if I have to use B_T in the head file of A and A_T in the head file of B?

In A.hpp, I need to include B.hpp and use B::B_T, so as for B. Then there must be a cross reference, how to solve it?

4

1 回答 1

2

If they are the same type, and they need to remain interopable between classes, then put the typedefs in a header file, and include the header file in both of your class definitions.

// Types.h
#pragma once

typedef int A_T;
typedef double B_T;
于 2013-03-30T08:42:24.377 回答