This should teach you not to have nasty using directives, such as:
using namespace std;
And especially not in the area of โโthe namespace (even worse if in the header files). There is a function std::time() in the standard library whose name collides with the name of your type.
This ambiguity can be resolved using the class keyword in the t declaration:
class time t;
However, a much better way would be to remove the using directive and define entity names from the standard namespace, thus writing (for example):
std::cout << "Initial universal time: "
Note that this may not be enough, since library implementations are allowed to put objects from the standard C library into the global namespace. In this case, removing the disgusting using directive would not help eliminate the ambiguity.
Therefore, I also suggest avoiding giving your own entities (types, functions, variables, ...) the same name as entities from the standard library, or putting them in your own namespace at least.
In addition, expressions such as:
cout << "Initial universal time: " << t.printuniversal();
Poorly formed since printuniversal() returns void . You should just do:
cout << "Initial universal time: "; t.printuniversal();
The same applies to all similar expressions.
source share