出现C4430问题,怎么解决?

在头文件的59、70行出现该问题,若改为bool,void,int类型,越改问题越多,应该怎么改?头文件理应不会有顺序错误或者重复包含的问题

//LinkedBinTree.h
#include"stdafx.h"

#include<iostream>
using namespace std;

template<class T>
class LinkedNode
{
	template<class T>
	friend class LinkedBinTree;
public:
	LinkedNode()
	{
		m_pLeftChild=m_pRightChild=NULL;
	}
	LinkedNode(const T &x)
	{
		m_pLeftChild=m_pRightChild=NULL;
		m_data=x;
	}
private:
	T m_data;
	LinkedNode<T>*m_pLeftChild,*m_pRightChild;
};

template<class T>
class LinkedBinTree
{
public:
	LinkedBinTree();
	~LinkedBinTree();
	bool IsEmpty();
	LinkedNode<T>*CreateRoot(const T&x);
	LinkedNode<T>*GetRoot();
	bool GetNodeValue(LinkedNode<T>*pNode, T &x);
	 LinkedNode<T>*InsertLeftChild(LinkedNode<T>*pNode,const T&x);
     LinkedNode<T>*InsertRightChild(LinkedNode<T>*pNode,const T&x);
	bool GetLeftChild(LinkedNode<T>*pNode);
	bool GetRightChild(LinkedNode<T>*pNode);
	void InOrderTraverse(LinkedNode<T>*pNode);
private:
	LinkedNode<T>*m_pRoot;};

template<class T>
LinkedBinTree<T>::LinkedBinTree()
{
	m_pRoot=NULL;}

template<class T>
int LinkedBinTree<T>::InsertLeftChild(LinkedNode<T>*pNode,const T&x)
{
	LinkedNode<T>*pNewNode;
	if(pNode==NULL)
		return NULL;
	pNewNode=new LinkedNode<T>(x);
	if(pNewNode==NULL)
		return NULL;
	pNode->m_pLeftChild=pNewNode;
	return pNewNode;}

template<class T>
LinkedBinTree<T>::InsertRightChild(LinkedNode<T>*pNode,const T&x)
{
	LinkedNode<T>*pNewNode;
	if(pNode==NULL)
		return NULL;
	pNewNode=new LinkedNode<T>(x);
	if(pNewNode==NULL)
		return NULL;
	pNode->m_pRightChild=pNewNode;
	return pNewNode;}


template<class T>
LinkedNode<T>*LinkedBinTree<T>::CreateRoot(const T&x)
{
	if(m_pRoot!=NULL)
		m_pRoot->m_data=x;
	else
		m_pRoot=new LinkedNode<T>(x);
	return m_pRoot;}

template<class T>
LinkedNode<T>*LinkedBinTree<T>::GetRoot()
{
	return m_proot;}

template<class T>
bool LinkedBinTree<T>::GetNodeValue(LinkedNode<T>*pNode,T&x)
{
	if(pNode==NULL)
		return false;
	x=pNode->m_data;
	return true;}

template<class T>
bool GetLeftChild(LinkedNode<T>*pNode)
{ if(pNode==NULL)
  return NULL;
return pNode->m_pLeftChild;
}

template<class T>
bool GetRightChild(LinkedNode<T>*pNode)
{
	if(pNode==NULL)
		return NULL;
	return pNode->m_pRightChild;}




template<class T>
void InsertBST(LinkedBinTree<T>&btree,T K)
{
	LinkedNode<T>*pNode=NULL,*pChild=NULL;
	T x;
	if(btree.IsEmpty())
	{
		btree.CreateRoot(K);
		return ;}
	pNode=btree.GetRoot();
	while(pNode)
	{
		btree.GetNodeValue(pNode,x);
		if(K==x)
			return;
		if(K<x)
		{
			if((pChild=btree.GetLeftChild(pNode))!=NULL)
				pNode=pChild;
			else
			{
				btree.InsertLeftChild(pNode,K);
				return;
			}
		}
		else
		{
			if((pChild=btree.GetRightChild(pNode))!=NULL)
				pNode=pChild;
			else
			{
				btree.InsertRightChild(pNode,K);
				return;
			}
		}
	}
}

template<class T>
void CreateBST(T R[],int nSize,LinkedBinTree<T>&btree)
{
	int nI;
	for(nI=1;nI<nSize;nI++)
		InsertBST(btree,R[nI]);
}

template<class T>
LinkedNode<T>*SearchInsertBST(LinkedBinTree<T>&btree,T K)
{
	LinkedNode<T>*pNode=NULL,*pChild=NULL;
	T x;
	if(btree.IsEmpty())
	{
		btree.CreateRoot(K);
		return NULL;
	}
	pNode=btree.GetRoot();
	while(pNode)
	{
		btree.GetNodeValue(pNode,x);
		if(K==x)
			return pNode;
		if(K<x)
		{
			if((pChild=btree.GetLeftChild(pNode))!=NULL)
				pNode=pChild;
			else
			{
				btree.InsertLeftChild(pNode,K);
				return NULL;
			}
		}
		else
		{
			if((pChild=btree.GetRightChild(pNode))!=NULL)
				pNode=pChild;
			else
			{
				btree.InsertRightChild(pNode,K);
				return NULL;
			}
		}
	}
	return NULL;
}

template<class T>
void LinkedBinTree<T>::InOrderTraverse(LinkedNode<T>*pNode)
{
	if(pNode==NULL)
		return;
	InOrderTraverse(pNode->m_pLeftChild);
	InOrderTraverse(pNode->m_pRightChild);
}


//A.cpp
#include "stdafx.h"
#include"LinkedBinTree.h"

#include<iostream>
using namespace std;

int main()
{ int nR[]={0,43,56,37,28,17,39,22};
  int nSize=sizeof(nR)/sizeof(nR[0]);
  int nK=39,nX=0;
  LinkedBinTree<int>btree;
  LinkedNode<int>*pNode=NULL;
  CreateBST(nR,nSize,btree);
  btree.InOrderTraverse(pNode);
  cout<<endl;
  pNode=SearchInsertBST(btree,nK);
  if(pNode!=NULL)
  {
	  btree.GetNodeValue(pNode,nX);
	  cout<<nX<<"查找成功"<<endl;
  }
  else
	  cout<<"查找失败"<<endl;
	return 0;
}

 

定义的是int类型,return的不是 

你这贴在这个问题里的里第51行改为:

LinkedNode<T>* LinkedBinTree<T>::InsertLeftChild(LinkedNode<T>* pNode, const T& x)

第63行改为:

LinkedNode<T>*  LinkedBinTree<T>::InsertRightChild(LinkedNode<T>* pNode, const T& x)

第87行改为:

return m_pRoot;}

然后39,40行的两个函数,应该返回LinkedNode<T>*指针而不是bool,并且你没给全代码,没有他们的实现,只有声明,请先补全实现。

bool GetLeftChild(LinkedNode<T>* pNode);
bool GetRightChild(LinkedNode<T>* pNode);