-1

For class I made a struct called time and the h.which looked something like this

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);

Later our teacher had us make another program which used the same code in this program. Rather than writing it over i included. First question is this a legitimate #include (assuming the path is correct)

#include "../p*/*r*/0*/*s/02*/time.h"

Second question I need to use the convert function in the program im currently working on. How would i go about doing this? would i use the scope resolution operator as follows

timeobeject=Time::convert(t,time); 

or like this

timeobject=convert(t,time);
mwerschy
  • 1,698
  • 1
  • 15
  • 26
B4dmonkey
  • 112
  • 1
  • 2
  • 12
  • To better adjust to the moving of header files or source files, don't put paths in the `#include` statement. Supply the paths as search directories to the compiler (-I) or to the build system / IDE. – Thomas Matthews May 26 '13 at 17:42

1 Answers1

1

First question is this a legitimate #include (assuming the path is correct)

#include "../p*/r/0*/s/02/time.h"

Yes. But remember to compile the implementation file of it as well with the current project. Or you can link directly to the object file.

timeobeject=Time::convert(t,time);

Wrong. convert function isn't enclosed in any namespace. You have to directly call it like -

timeobeject=convert(t,time); 
Mahesh
  • 34,573
  • 20
  • 89
  • 115