GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 23-May-2006, 23:56
mia mia is offline
New Member
 
Join Date: Apr 2006
Posts: 22
mia is on a distinguished road

Fatal error C1083: Cannot open include file


I'm using Visual Studio 2005
I have this:
BNode.

CPP / C++ / C Code:
#include "stdafx.h"

template<typename sometype>
class BNode
{
private:

	BNode<sometype> *father;
	BNode<sometype> *left;
	BNode<sometype> *right;
	sometype dato;

public:

	BNode(const sometype & dato,BNode<sometype> * father = NULL, 
	BNode<sometype>*leftson=NULL,BNode<sometype> *rightson=NULL);
	BNode<sometype> * getleft()const;
	BNode<sometype> * getright()const;
	BNode<sometype> * getfather()const;
	sometype getdato()const;
	void setleft(BNode<sometype> * leftson);
	void setright(BNode<sometype> * rightson);
	void setfather(BNode<sometype> * father);
	bool hastwosons()const;
	bool hasleftson()const;
	bool hasrightson()const;
	void setdato(const sometype & dato);
	void showdato()const;

};

template<typename sometype>
BNode<sometype>::BNode(const sometype &dato,BNode<sometype> * father, BNode<sometype> *leftson, BNode<sometype> *rightson)
{
	this->father = father;
	this->dato = dato;
	this->left = leftson;
	this->right = rightson;
}

template<typename sometype>
BNode<sometype> * BNode<sometype>::getfather() const
{
	return this->father;
}

template<typename sometype>
BNode<sometype> * BNode<sometype>::getleft() const
{
	return this->left;
}

template<typename sometype>
BNode<sometype> * BNode<sometype>::getright() const
{
	return this->right;
}

template<typename sometype>
sometype BNode<sometype>::getdato() const
{
	return this->dato;
}

template<typename sometype>
void BNode<sometype>::setfather(BNode<sometype> *father)
{
	this->father = father;
}

template<typename sometype>
void BNode<sometype>::setleft(BNode<sometype> *leftson)
{
	this->left = leftson;
}

template<typename sometype>
void BNode<sometype>::setright(BNode<sometype> *rightson)
{
	this->right = rightson;
}

template<typename sometype>
void BNode<sometype>::setdato(const sometype &dato)
{
	this->dato;
}

template<typename sometype>
void BNode<sometype>::showdato() const
{
	cout<<this->dato;
}

template<typename sometype>
bool BNode<sometype>::hastwosons() const
{
	return (this->left != NULL && this->right != NULL);
}

template<typename sometype>
bool BNode<sometype>::hasleftson() const
{
	return (this->left != NULL);
}

template<typename sometype>
bool BNode<sometype>::hasrightson() const
{
	return (this->right != NULL);
}

which works fine.

&& i have
BST

CPP / C++ / C Code:
#include "stdafx.h"
#include "BNode.h"
template<typename sometype, typename keytype>
class BST
{
protected:

	Bnode<sometype> * root;
	Bnode<sometype> * copySubtree(Bnode<sometype> * root);
	Bnode<sometype> * founddata(Bnode<sometype> * root, const keytype & key)const;
	void showinorder(Bnode<sometype> * root)const;
	bool insertdata(Bnode<sometype> * root, const sometype & dato);
	void empty(Bnode<sometype> * root);

public:

	BST();
	BST(const BST<sometype,keytype> & aBSTtree);
	~BST();
	bool insertDato(const sometype & dato);
	bool hasDato(const keytype key)const;
	sometype getdato(const keytype key)const;
	bool isEmpty()const;
	void empty();
	void showInOrder()const;
	void showPreOrder()const;
	void showPostOrder()const;
	bool removeDato(const keytype & key);
	bool copySubTree(BST<sometype,keytype> & aBSTtree);
	
};

template<typename sometype, typename keytype>
BST<sometype,keytype>::BST()
{
	this->root=NULL;
}

template<typename sometype, typename keytype>
BST<sometype,keytype>::BST(const BST<sometype,keytype> &aBSTtree)
{
	this->root = this->copySubtree(aBSTtree.root);
}

template<typename sometype, typename keytype>
Bnode<sometype> * BST<sometype,keytype>::copySubtree(Bnode<sometype> *root)
{
	Bnode<sometype> *newRoot=NULL;
	
	if(root != NULL)
	{
		root = new BNode<sometype>(root->getDato());
		newRoot->setleft(this->copySubtree(root->getleft()));
		newRoot->setright(this->copySubtree(root->getright()));
	}

	return newRoot;
}

template<typename sometype, typename keytype>
BST<sometype,keytype>::~BST()
{
	this->empty();
}

template<typename sometype, typename keytype>
bool BST<sometype,keytype>::insertDato(const sometype &dato)
{
	bool inserted = true;

	if(root != NULL)
	inserted = this->insertdata(this->root,dato);
	else
		this->root = new Bnode<sometype>(dato);
	
	return inserted;

}

template<typename sometype, typename keytype>
bool BST<sometype,keytype>::hasDato(const keytype key) const
{
	return (this->founddata(this->root, key));
}

template<typename sometype, typename keytype>
sometype BST<sometype,keytype>::getdato(const keytype key) const
{
	return this->founddata(this->root,key)->getdato();
}

template<typename sometype, typename keytype>
bool BST<sometype,keytype>::isEmpty() const
{
	return (this->root==NULL);
}

template<typename sometype, typename keytype>
void BST<sometype,keytype>::empty()
{
	this->empty(this->root);
	this->root = NULL;

}

template<typename sometype, typename keytype>
void BST<sometype,keytype>::showInOrder() const
{
	this->showinorder(this->root);
}

template<typename sometype, typename keytype>
void BST<sometype,keytype>::showinorder(Bnode<sometype> *root) const
{
	if(root != NULL)
	{
		this->showinorder(root->getleft());
		cout<<root->getdato()<<endl;
		this->showinorder(root->getright());
	}

}
template<typename sometype, typename keytype>
void BST<sometype,keytype>::showPostOrder() const
{

}

template<typename sometype, typename keytype>
void BST<sometype,keytype>::showPreOrder() const
{

}

template<typename sometype, typename keytype>
bool BST<sometype,keytype>::removeDato(const keytype & key)
{
	bool removed = false;
	Bnode<sometype> * nodeToDelete, * sustituto;
	nodeToDelete = this->founddata(this->root,key);

				if(nodeToDelete != NULL)
				{
						if(nodeToDelete->hastwosons())
						{
							sustituto= nodeToDelete->getleft();
								if(sustituto->hasrightson())
								{
										while(sustituto->hasrightson() != NULL)
											sustituto = sustituto->getright();

										sustituto->getfather()->setright(sustituto->getleft());
										if(sustituto->hasleftson())
											sustituto->getleft()->setfather(sustituto->getfather());
										
										sustituto->setleft(nodeToDelete->getleft());
										nodeToDelete->getleft()->setfather(sustituto);
								}

							sustituto->setright(nodeToDelete->getright());
							nodeToDelete->getright()->setfather(sustituto);

							sustituto->setfather(nodeToDelete->getfather());

							if(nodeToDelete == this->root)
								this->root = sustituto;
							else
								nodeToDelete->getfather()->setleft(sustituto);
						}
						else
						{
							if(nodeToDelete!=this->root && nodeToDelete->hasleftson())//area changed
							{
										sustituto = nodeToDelete->getleft();
										if(nodeToDelete->getfather()->getleft() == nodeToDelete)
										{
											if(nodeToDelete != this->root)
												nodeToDelete->getfather()->setleft(sustituto);
											sustituto->setfather(nodeToDelete->getfather());
										}
										else
										{
											if(nodeToDelete != this->root)
												nodeToDelete->getfather()->setright(sustituto);
											sustituto->setfather(nodeToDelete->getfather());
										}
							}
									else
										if(nodeToDelete!=this->root && nodeToDelete->hasrightson())//area changed
										{
													sustituto = nodeToDelete->getright();
													if(nodeToDelete->getfather()->getleft() == nodeToDelete)
													{
															if(nodeToDelete != this->root)
																nodeToDelete->getfather()->setleft(sustituto);
															sustituto->setfather(nodeToDelete->getfather());
													}
													else
													{
																if(nodeToDelete != this->root)
																	nodeToDelete->getfather()->setright(sustituto);
																sustituto->setfather(nodeToDelete->getfather());
													}
													if(nodeToDelete == this->root)
														this->root = sustituto;
										}
										else
										{
													if(nodeToDelete != this->root)
														if(nodeToDelete->getfather()->getleft() == nodeToDelete)
															nodeToDelete->getfather()->setleft(NULL);
														else
															nodeToDelete->getfather()->setright(NULL);
													else
														this->root= NULL;
										}


						}
						delete nodeToDelete;
						removed = true;
			}
			return removed;

}

template<typename sometype, typename keytype>
void BST<sometype,keytype>::empty(Bnode<sometype> *root)
{
	if(root != NULL)
	{
		this->empty(root->getleft());
		this->empty(root->getright());
		delete root;
	}

}

template<typename sometype, typename keytype>
Bnode<sometype> * BST<sometype,keytype>::founddata(Bnode<sometype> *root, const keytype &key) const
{
	Bnode<sometype> * found = NULL;
	if(root != NULL)
		if(root->getdato().getkey() > key)
			found = this->founddata(root->getleft(),key);
		else
			if(root->getdato().getkey() < key)
				found = this->founddata(root->getright(),key);
			else
				found = root;
	
	return found;

}

template<typename sometype, typename keytype>
bool BST<sometype, keytype>::insertdata(Bnode<sometype> *root, const sometype &dato)
{
	bool inserted = false;
	if(root->getdato().getkey() > dato.getkey())
		if(root->hasleftson())
			inserted = this->insertdata(root->getleft(),dato);
		else
		{
			root->setleft(new Bnode<sometype>(dato,root));
			inserted = true;
		}
	else
	{
		if(root->getdato().getkey()< dato.getkey())
			if(root->hasrightson())
				inserted = this->insertdata(root->getright(),dato);
			else
			{
				root->setright(new Bnode<sometype>(dato,root));
				inserted = true;
			}

	}
		
		return inserted;

}

but i keep getting this error when compiling BST:
Error 1 fatal error C1083: Cannot open include file: 'BNode.h': No such file or directory c:\documents and settings\marita\my documents\visual studio 2005\projects\test\test\test.cpp 17

WHAT could it be?
Last edited by admin : 24-May-2006 at 09:22. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 24-May-2006, 01:09
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Fatal error C1083: Cannot open include file


Could be that
BNode.h is not the name of the file or
BNode.h is not in c:\documents and settings\marita\my documents\visual studio 2005\projects\test\test\ or
BNode.h has not been added to the project
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
  #3  
Old 24-May-2006, 09:20
mia mia is offline
New Member
 
Join Date: Apr 2006
Posts: 22
mia is on a distinguished road

Re: Fatal error C1083: Cannot open include file


I checked and its all how it is supposed to be:
I deleted the BNode.h and ADDED it again and now i get this:
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib

&&
Error 2 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\Marita\My Documents\Visual Studio 2005\Projects\Test\Debug\Test.exe
  #4  
Old 24-May-2006, 13:28
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: Fatal error C1083: Cannot open include file


This is because you do not have a main function in either file -- is there another source file? Or are you trying to compile a static library/DLL (then you would have to set that in the compiler options)?
  #5  
Old 14-May-2007, 14:24
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road
Unhappy

Re: Fatal error C1083: Cannot open include file


Hiya,

I'm having a similar problem...

see this thread where I've posted my code and error message:
"http://www.gidforums.com/t-14299.html?highlight=linked+list"

I've got "graphics_lib.h" in the following files:
"C:\Documents and Settings\...\shapeshifter\shapeshifter\graphics_li b\HERE"
C:\Documents and Settings\...\shapeshifter\shapeshifter\HERE"
"C:\Documents and Settings\...\shapeshifter\graphics_lib\& HERE"

I've added it to the project and stuck it into the header file on the folder tree in the top left o' screen (I'm using MS Visual C++ 6 btw)

and I get the same error message (as the other thread shows).

Please could someone help?
  #6  
Old 14-May-2007, 15:35
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,641
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Fatal error C1083: Cannot open include file


Quote:
Originally Posted by promsan
and I get the same error message.
Please could someone help?

See my response to the new thread you started on the C board. Traditionally, files included with angle brackets '<>' are on some magical path that the compiler searches for standard library headers and headers for its own library files. Use quote marks " " for header files that are in the same directory as the C or C++ files that include them. Alternatively, use the command-line compiler switch "-I" to specify special paths for your own included headers.

Regards,

Dave
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
Cannot open include file ? 'can.h' PeteGallo MS Visual C++ / MFC Forum 2 26-Feb-2006 22:19
fltk-2.0 cvs Plumb FLTK Forum 20 13-Nov-2004 07:10
help with classes bucho MS Visual C++ / MFC Forum 3 20-Oct-2004 06:16
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:32.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.