I am just confused as to what my file is supposed to look like. I am not sure on the syntax as well as how to read in the array.
I'm just confused as to what my Map.cpp file is supposed to look like.
Map class
which takes std::string as a parameter. Provide one!
template <typename Domain, typename Range>
class Map
{
public:
Map(const std::string& filename); // declare one constructor which takes std::string
// ... other members
};
Thirdly, your member function definitions missing the template parameters.
template <typename Domain, typename Range> // ---> this
void Map<Domain, Range>::add(Domain d, Range r)
{
// implementation
}
template <typename Domain, typename Range> // ---> this
bool Map<Domain, Range>::lookup(Domain d, Range& r)
{
// implementation
}
Map class, as the allocated memory(using new)
should be freed. Therefore, do accordingly the The rule of
three/five/zero.That being said, if you could have used std::vector, the manual memory management could be avoided.
#include <vector>
template <typename Domain, typename Range>
class Map
{
public:
//...
private:
// other members
std::vector<Domain> dArray;
std::vector<Range> rArray;
};
As a side note, avoid practising with using namespace std;.
Why is "using namespace std;" considered bad practice?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With