j***i 发帖数: 1278 | 1 看c++ template数书上有段
Types that involve unnamed class types or unnamed enumeration types cannot b
e template type arguments (unnamed classes or enumerations that are given a
name through a typedef declaration are OK).
An example illustrates these two exceptions:
template class List {
…
};
typedef struct {
double x, y, z;
} Point;
typedef enum { red, green, blue } *ColorPtr;
int main()
{
struct Association
{
int* p;
int* q;
};
List e | r****t 发帖数: 10904 | 2 enum type 也还是没有 named 啊。
cannot b
given a
【在 j***i 的大作中提到】 : 看c++ template数书上有段 : Types that involve unnamed class types or unnamed enumeration types cannot b : e template type arguments (unnamed classes or enumerations that are given a : name through a typedef declaration are OK). : An example illustrates these two exceptions: : template class List { : … : }; : typedef struct { : double x, y, z;
| I*****y 发帖数: 602 | 3 我的理解:
typedef enum { red, green, blue } *ColorPtr;
ColorPtr是个指针类型,指向无名的enum类型。
修改为:
typedef enum Color { red, green, blue } *ColorPtr;
可以通过编译。
而你定义的Point则是一个实实在在的无名的struct类型的别名。
b
a
【在 j***i 的大作中提到】 : 看c++ template数书上有段 : Types that involve unnamed class types or unnamed enumeration types cannot b : e template type arguments (unnamed classes or enumerations that are given a : name through a typedef declaration are OK). : An example illustrates these two exceptions: : template class List { : … : }; : typedef struct { : double x, y, z;
|
|