.cpp ファイルから .h ファイルの enum UDT Month を呼び出そうとすると、コンパイラでエラーが発生します。列挙型 UDT を別のファイルで使用できますか? もしそうなら、どのように?
私の日付.h
class Date
{
public:
enum Month
{
jan = 1,
feb,
mar,
apr,
may,
jun,
jul,
aug,
sep,
oct,
nov,
dec
};
Month int_to_month(int x);
Date(int y, Month m, int d);
Month month () const;
...other code
};
コンパイラは、date.cpp ファイル内の Month および関数名に対する次の参照のエラーを強調表示します。
#include "lib.h"
#include "date.h"
Month Date::month () const
{
return m;
}
Month Date::int_to_month(int x)
{
return m;
}