求大牛救一下小弟,关于VC6.0的error C2838: illegal qualified name in member declaration
小弟的课设就是弄一个二叉树来存储一串字符串的各单词出现次数,但是编译的时候出现了这个错误 我绞尽脑汁都想不出来,望大神拯救,错误是我类外定义的函数名,我一直不知道错在哪。。。
下面有全部代码
这个是类:
#include<iostream>
using namespace std;
#include"Binarynode1.h"
#include"string"
class Binarysorttree
{
public:
Binarynode1 *root;
string *words;
void insert(string key);
void inorder();
void inorder(Binarynode1*p);
Binarysorttree(string str,int n);
};
Binarysorttree::Binarysorttree(string str,int n)
{
int word=1;
for(int i=0;i<n;i++)
{
if(str[i]==' ')
word++;
}
this->words=new string[word];
int j=0;
for(i=0;i<n;i++)
{
if(str[i]!=' ')
words[j]+=str[i];
else
j++;
}
for(i=0;i<word;i++)
this->insert(str[i]);
}
void Binarysorttree::insert(string key)
{
if(this->root==NULL)
this->root=new Binarynode1(key);
Binarynode1*p=this->root,*parent=NULL;
while(!p=NULL)
{
if(p->data==key)
{
p->num++;
return;
}
parent=p;
if(key[0]<=p->data[0])
p=p->left;
else
p=p->right;
}
if(key[0]<=parent->data[0])
parent->left=new Binarynode1(key);
else
parent->right=new Binarynode1(key);
}
void Binarysorttree::inorder()
{
cout<<"中根次序遍历二叉树:";
this->inorder(root);
cout<<endl;
}
void Binarysorttree::inorder(Binarynode1 *p)
{
if(p!=NULL)
{
inorder(p->left);
cout<<p->data<<"("<<p->num<<") ";
inorder(p->right);
}
}
主函数:
#include<iostream>
using namespace std;
#include "string"
#include"Binarysorttree.h"
int main()
{
string a="What can I do and how to do";
Binarysorttree str2(a,a.length());
str2.inorder():
return 0;
}