I was hoping someone could help me out with an error I'm having using an enum class in a switch case. trying to use the traverse type to choose the path in the switch. Here is my code:
enum class TraverseType { PREORDER, INORDER, POSTORDER, BREADTHORDER };
private:
TraverseType traverseOrder;
public:
friend ostream& operator<<(ostream& out, const BTree& tree)
{
TraverseType type = traverseOrder;//error
switch (type)
{
case TraverseType::PREORDER:
{
break;
}
case TraverseType::INORDER:
{
break;
}
case TraverseType::POSTORDER:
{
break;
}
case TraverseType::BREADTHORDER:
{
break;
}
default:
{
break;
}
}
return out;
}`
the error im getting is : Error C2440 'initializing': cannot convert from 'unknown' to 'TraverseType' and i have been trying to find a solution to this problem for hours now. If you need more code please let me know. Thank you for your help in advance
enum class TraverseType { PREORDER, INORDER, POSTORDER, BREADTHORDER };<-- enum ends here. The code that follows is... not in anything and it's confusing the poor compiler. And me. What are you trying to do here? What's the goal?enum class TraverseType { PREORDER, INORDER, POSTORDER, BREADTHORDER };class BTree { private:note theclass BTree {stuffed in there.