在结构中使用大写字母和小写字母的区别
Difference in using capital and small letters within a structure
当我使用 "distance" 和 "time" 作为我的结构的标识符名称时,出现错误。编译器说 对 "distance" 的引用不明确。
#include <iostream>
using namespace std;
struct distance{
float feet;
float inches;
};
struct time {
int hrs;
int mins;
int secs;
};
int main()
{
struct tour {
distance d;
time t;
};
return 0;
}
但是当我使用大写字母时,"Distance"和"Time",
#include <iostream>
using namespace std;
struct Distance{
float feet;
float inches;
};
struct Time {
int hrs;
int mins;
int secs;
};
int main()
{
struct tour {
Distance d;
Time t;
};
return 0;
}
编译器没有显示任何错误。谁能告诉我原因吗?
当我使用 "distance" 和 "time" 作为我的结构的标识符名称时,出现错误。编译器说 对 "distance" 的引用不明确。
#include <iostream>
using namespace std;
struct distance{
float feet;
float inches;
};
struct time {
int hrs;
int mins;
int secs;
};
int main()
{
struct tour {
distance d;
time t;
};
return 0;
}
但是当我使用大写字母时,"Distance"和"Time",
#include <iostream>
using namespace std;
struct Distance{
float feet;
float inches;
};
struct Time {
int hrs;
int mins;
int secs;
};
int main()
{
struct tour {
Distance d;
Time t;
};
return 0;
}
编译器没有显示任何错误。谁能告诉我原因吗?