0

私は現在、数千の名前を持つテキスト ファイルを実行し、それらをバイナリ ストレージ ツリーに配置するプロジェクトを持っています。このエラーでつまずきます:

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);
}
}
4

1 に答える 1

1

関数内:をwriteコピーすることはできませんofstream。参照で渡します。繰り返しになりますが、本体で関数引数を使用することはないようですnameOut。それを完全に省略しないでください。

void BinaryTreeStorage::write()
{
    cout << "Writing out bst names" << endl;
    writeToTree(root);
}
于 2012-05-07T12:49:09.950 に答える