【发布时间】:2013-05-26 14:42:39
【问题描述】:
对于类,我创建了一个名为 time 的结构和 h.which 看起来像这样
struct Time{
Time() : hours(0),minutes(0),seconds(0),ticks(0){}
int hours, minutes, seconds, ticks;
};
Time convert (clock_t t, Time &time);
std::string hmst(Time &time);
std::string hmst(clock_t t);
后来我们的老师让我们制作了另一个程序,在这个程序中使用了相同的代码。而不是把它写在我包括在内。第一个问题是这是一个合法的#include(假设路径正确)
#include "../p*/*r*/0*/*s/02*/time.h"
第二个问题我需要在我当前正在处理的程序中使用转换功能。我该怎么做呢?我会按如下方式使用范围解析运算符吗
timeobeject=Time::convert(t,time);
或者像这样
timeobject=convert(t,time);
【问题讨论】:
-
为了更好地适应头文件或源文件的移动,不要在
#include语句中放置路径。将路径作为搜索目录提供给编译器 (-I) 或构建系统/IDE。
标签: c++ include scope header-files include-path