I'm working at creating a class that is a binary tree. I would like to simplify this by creating a class that stores the data in an array, and then go back and make the magic happen.
However, the commented out line in the following section of code causes Visual Studio to spew ton of errors. It makes sense to me, but for some reason it won't compile. I'm not a C++ guy, but after a lot of Googling, nothing is working for me.
template
class bin_tree
{
private:
int *data;
public:
int getData(int x)
{
return 1;
};
bin_tree() : data(new int[4])
{
//data = {1, 2, 3, 4};
};
};
dataarray?templateat the beginning of your class definition?bin_tree() : data{1, 2, 3, 4} {}.