我目前有一个项目,我通过一个包含数千个名称的文本文件运行并将它们放入二进制存储树中。遇到此错误的绊脚石:
error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\program files (x86)\microsoft visual studio 10.0\vc\include\fstream 1116
我希望有人可以帮助我解释根本问题。
提前致谢。
乔希
编辑:
BinaryTreeStorage::BinaryTreeStorage(void) : root(NULL)
{
}
BinaryTreeStorage::~BinaryTreeStorage(void)
{
}
void BinaryTreeStorage::insert(string &input, TreeNode *&root)
{
if(root != NULL)
{
root -> name = input;
root -> left = NULL;
root -> right = NULL;
}
else if (input < root -> name)
{
insert(input, root -> left);
}
else
{
insert(input, root -> left);
}
}
string BinaryTreeStorage:: writeToTree(TreeNode *&root)
{
if(root ->left != NULL)
{
writeToTree(root ->left);
}
return root->name;
if (root->right != NULL)
{
writeToTree(root);
}
}
void BinaryTreeStorage::write(ofstream nameOut)
{
cout << "Writing out bst names" << endl;
writeToTree(root);
}
void BinaryTreeStorage::read(ifstream& nameIn)
{
cout<< "Reading in bst" << endl;
string name;
for (int i = 0; i < numberOfNames; i++)
{
nameIn >> name;
insert (name, root);
}
}