std::ostream& operator<<(std::ostream& out, const HashNode</*empty*/>& node) { return out << "[ " << "key: " << node.getKey() << ", " << "val: " << node.getValue() << " ]"; }
//REM: HashNode.h template<typename K = int, typename V = std::string> class HashNode { ... }; template<typename K = int, typename V = std::string> std::ostream& operator<<(std::ostream& out, const HashNode<K, V>& node) { out << "[ " << "key: " << node.getKey() << ", " << "val: " << node.getValue() << " ]"; return out; } //REM: then we stream it out //HashNode<float, int> hNodeF = new HashNode<float, int>(); HashNode<>* hNode = new HashNode<>(); hNode->setKey(777); hNode->setValue("lucky?"); std::cout << hNode << std::endl; // why only an address or reference show up, why does my overload operator not working? delete hNode;
std::cout << *hNode << std::endl;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)