I have a class, Tracker
, where I declare an alias
From Tracker.h
:
class Tracker {
...
using ArgsMap = std::unordered_map<std::string, std::string>;
std::shared_ptr<ArgsMap> getArgsMapForTask(std::string task);
...
}
In the .cpp file, where I define the function:
#include Tracker.h
...
// ArgsMap here gives error: Use of undeclared identifier 'ArgsMap'
std::shared_ptr<ArgsMap> Tracker::getArgsMapForTask(std::string taskName)
{
ArgsMap a; // this gives no error, compiler recognizes ArgsMap
}
How can I use ArgsMap
in the function signature?
The problem is not that the alias is in the header file, that's totally irrelevant.
The problem is that the alias is defined in the scope of the class, so you need to qualify it if you want to use it outside of the class: Tracker::ArgsMap
.