Hello, I'm new to C++ but after reading two books regardin this language I made this part of a program. While those two files (.h and .cpp) were concatenated in the main cpp file the program worked without errors, aldo it did not return anythig. As I split the program to header files I have several errors:

Error	3	error C1083: Cannot open include file: 'lists': No such file or directory	i:\sync\sortwaternetwork\sortwaternetwork\noduri.h	4
Error	5	error C2871: 'sortWaterNetwork' : a namespace with this name does not exist	I:\Sync\sortWaterNetwork\sortWaterNetwork\fisier.cpp	5
Error	6	error C2653: 'clsFisier' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\fisier.cpp	7
Error	7	error C2645: no qualified name for pointer to member (found ':: *')	I:\Sync\sortWaterNetwork\sortWaterNetwork\fisier.cpp	7
Error	8	error C1903: unable to recover from previous error(s); stopping compilation	I:\Sync\sortWaterNetwork\sortWaterNetwork\fisier.cpp	7
Error	10	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	11	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	12	error C2146: syntax error : missing ')' before identifier 'element'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	13	error C2182: 'AddElement' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	14	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	15	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	7
Error	16	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	7
Error	17	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	18	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	19	error C2146: syntax error : missing ')' before identifier 'element'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	20	error C2182: 'InsertElement' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	21	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	22	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	11
Error	23	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	11
Error	24	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	14
Error	25	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	18
Error	26	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	22
Error	27	error C2061: syntax error : identifier 'list'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	22
Error	28	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	26
Error	29	error C2061: syntax error : identifier 'list'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	26
Error	30	error C2653: 'clsReservor' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	31
Error	31	error C2653: 'clsPumps' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	32	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	33	error C2146: syntax error : missing ')' before identifier 'elementIntrare'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	34	error C2182: 'SetNodIntrare' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	35	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	36	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	37
Error	37	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	37
Error	38	error C2653: 'clsPumps' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	39	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	40	error C2146: syntax error : missing ')' before identifier 'elementIesire'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	41	error C2182: 'SetNodIesire' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	42	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	43	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	41
Error	44	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	41
Error	45	error C1083: Cannot open include file: 'lists': No such file or directory	i:\sync\sortwaternetwork\sortwaternetwork\noduri.h	4

I guess it all strats from this C2653 error which speads through all my new header files.


noduri.h source:

//noduri.h
#ifndef noduri_h
#define noduri_h

#include <list>

// using namespace std;

class clsElemente {
	private:
		unsigned int id;
		double x,y,elev;
	public:
		void AddElement(clsElemente element);		//adauga element la sfarsitul listei
		void InsertElement(clsElemente element);	//insereaza element in locatia curenta a listei
		void SetId(unsigned int idNou);			//seteaza noul ID al elementului
		unsigned int GetID(char *tip);			//preia ID-ul elementului
		void CautaElementeTip(char *tip, list<clsElemente>& elemente);					//cauta elemente de un anumit tip
		unsigned int CautaNumarAparitii(unsigned int id, list<clsElemente>& elemente);	//cauta un numar de aparitii a unui element intr-o lista

};

class clsNoduri : clsElemente {
	};

class clsReservoir : clsElemente {
	public:
		unsigned int CautaElevatieMaxima();
};

class clsTanks : clsElemente {
};

class clsPumps : clsElemente {
	private: 
		unsigned int nodIntrare, nodIesire;
	public:
		void SetNodIntrare(clsElemente elementIntrare);
		void SetNodIesire(clsElemente elementIesire);
};

class clsValves : clsElemente {
};

#endif

noduri.cpp source:

//noduri.cpp
#include "noduri.h"
#include "stdafx.h"

using namespace std;

void clsElemente::AddElement (clsElemente element) //adauga element la sfarsitul listei
{
} //void clsElemente::AddElement(clsElemente element)

void clsElemente::InsertElement (clsElemente element) //insereaza element in locatia curenta a listei
{
} //void clsElemente::InsertElement(clsElemente element)

void clsElemente::SetId (unsigned int idNou)			//seteaza noul ID al elementului
{
} //void clsElemente::SetId(unsigned int idNou)

unsigned int clsElemente::GetID(char *tip)			//preia ID-ul elementului
{
} //unsigned int clsElemente::GetID(char *tip)

void clsElemente::CautaElementeTip(char *tip, list<clsElemente>& elemente)					//cauta elemente de un anumit tip
{
} //void clsElemente::CautaElementeTip(char *tip, list<clsElemente>& elemente)

unsigned int clsElemente::CautaNumarAparitii(unsigned int id, list<clsElemente>& elemente)	//cauta un numar de aparitii a unui element intr-o lista
{
} //unsigned int clsElemente::CautaNumarAparitii(unsigned int id, list<clsElemente>& elemente)


unsigned int clsReservor::CautaElevatieMaxima()
{
}


void clsPumps::SetNodIntrare(clsElemente elementIntrare)
{
}

void clsPumps::SetNodIesire(clsElemente elementIesire)
{
}

Thanks.

Sorry. Forgot to mention that I use Windows 7 x64 and Microsoft Visual Studio 2010.

I guess it all strats from this C2653 error which speads through all my new header files.

The first error that occurs is:

Error	3	error C1083: Cannot open include file: 'lists': No such file or directory	i:\sync\sortwaternetwork\sortwaternetwork\noduri.h

However, that does not match the noduri.h/#include <list> that you posted - which somewhat implies that you might be working on one set of files but compiling another set of files.

Actually, those are from the same project. The only difference is that I modified temporarlly <list> with <lists> to see if it gives error (in other words, i was not shure what is the corect form). but i came back to the <list> statement and that's why you see that difference.
The idea is that even this error is missing if I do not use header files but only one file in the project.

Actually, those are from the same project. The only difference is that I modified temporarlly <list> with <lists> to see if it gives error

OK, as far as I understand, then the above error message listing is not a match for the code that you posted.
If that's the case, then please re-compile and re-post the actual errors.

[EDIT]
In the header file you have commented out using namespace std; and in at least two of the method declarations you are using list .

Those you can fix by ..

void CautaElementeTip(char *tip, std::list<clsElemente>& elemente);

Repost with the exact code and the exact error list. Sorry for my previous posts.

error list excluding the error for other header since the errors are the same :

Error	49	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	50	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	51	error C2146: syntax error : missing ')' before identifier 'element'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	52	error C2182: 'AddElement' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	53	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	6
Error	54	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	7
Error	55	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	7
Error	56	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	57	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	58	error C2146: syntax error : missing ')' before identifier 'element'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	59	error C2182: 'InsertElement' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	60	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	10
Error	61	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	11
Error	62	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	11
Error	63	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	14
Error	64	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	18
Error	65	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	22
Error	66	error C2061: syntax error : identifier 'list'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	22
Error	67	error C2653: 'clsElemente' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	26
Error	68	error C2061: syntax error : identifier 'list'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	26
Error	69	error C2653: 'clsReservor' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	31
Error	70	error C2653: 'clsPumps' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	71	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	72	error C2146: syntax error : missing ')' before identifier 'elementIntrare'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	73	error C2182: 'SetNodIntrare' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	74	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	36
Error	75	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	37
Error	76	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	37
Error	77	error C2653: 'clsPumps' : is not a class or namespace name	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	78	error C2065: 'clsElemente' : undeclared identifier	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	79	error C2146: syntax error : missing ')' before identifier 'elementIesire'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	80	error C2182: 'SetNodIesire' : illegal use of type 'void'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	81	error C2059: syntax error : ')'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	40
Error	82	error C2143: syntax error : missing ';' before '{'	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	41
Error	83	error C2447: '{' : missing function header (old-style formal list?)	I:\Sync\sortWaterNetwork\sortWaterNetwork\noduri.cpp	41
Error	84	error C1075: end of file found before the left brace '{' at 'i:\sync\sortwaternetwork\sortwaternetwork\Form1.h(7)' was matched	I:\Sync\sortWaterNetwork\sortWaterNetwork\sortWaterNetwork.cpp	20

the source for noduri.h:

#ifndef noduri_h
#define noduri_h

#include <list>

using namespace std;

class clsElemente {
	private:
		unsigned int id;
		double x,y,elev;
	public:
		void AddElement(clsElemente element);		//adauga element la sfarsitul listei
		void InsertElement(clsElemente element);	//insereaza element in locatia curenta a listei
		void SetId(unsigned int idNou);			//seteaza noul ID al elementului
		unsigned int GetID(char *tip);			//preia ID-ul elementului
		void CautaElementeTip(char *tip, list<clsElemente>& elemente);					//cauta elemente de un anumit tip
		unsigned int CautaNumarAparitii(unsigned int id, list<clsElemente>& elemente);	//cauta un numar de aparitii a unui element intr-o lista

};

class clsNoduri : clsElemente {
	};

class clsReservoir : clsElemente {
	public:
		unsigned int CautaElevatieMaxima();
};

class clsTanks : clsElemente {
};

class clsPumps : clsElemente {
	private: 
		unsigned int nodIntrare, nodIesire;
	public:
		void SetNodIntrare(clsElemente elementIntrare);
		void SetNodIesire(clsElemente elementIesire);
};

class clsValves : clsElemente {
};

#endif

the source for noduri.cpp

#include "noduri.h"
#include "stdafx.h"

using namespace std;

void clsElemente::AddElement (clsElemente element) //adauga element la sfarsitul listei
{
} //void clsElemente::AddElement(clsElemente element)

void clsElemente::InsertElement (clsElemente element) //insereaza element in locatia curenta a listei
{
} //void clsElemente::InsertElement(clsElemente element)

void clsElemente::SetId (unsigned int idNou)			//seteaza noul ID al elementului
{
} //void clsElemente::SetId(unsigned int idNou)

unsigned int clsElemente::GetID(char *tip)			//preia ID-ul elementului
{
} //unsigned int clsElemente::GetID(char *tip)

void clsElemente::CautaElementeTip(char *tip, list<clsElemente>& elemente)					//cauta elemente de un anumit tip
{
} //void clsElemente::CautaElementeTip(char *tip, list<clsElemente>& elemente)

unsigned int clsElemente::CautaNumarAparitii(unsigned int id, list<clsElemente>& elemente)	//cauta un numar de aparitii a unui element intr-o lista
{
} //unsigned int clsElemente::CautaNumarAparitii(unsigned int id, list<clsElemente>& elemente)


unsigned int clsReservor::CautaElevatieMaxima()
{
}


void clsPumps::SetNodIntrare(clsElemente elementIntrare)
{
}

void clsPumps::SetNodIesire(clsElemente elementIesire)
{
}

I think you have an issue with precompiled headers.
In the noduri.cpp file, switch the order of your #includes to be

#include "stdafx.h"  // <- first the precompiled header
#include "noduri.h"  // then other includes follow
...

The above Wikipedia link briefly explains your issue, MSDN documents it more thoroughly - it can be rather complicated actually. You may want to turn the precompiled headers option off altogether.

commented: Great help. +1

THANK YOU!

We're getting somewhere. There goes most of the errors. I think it was that simple.
But hey, why is that (since is precompiled before any class definition) ?

So, now I only have errors: "function must return value" which will be solved once I write the whole function.

But there is another error and I don't know how to solve it:

Error	2	error C1075: end of file found before the left brace '{' at 'i:\sync\sortwaternetwork\sortwaternetwork\Form1.h(7)' was matched	I:\Sync\sortWaterNetwork\sortWaterNetwork\sortWaterNetwork.cpp	20
// sortWaterNetwork.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"


using namespace sortWaterNetwork;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}

Are you sure these are all the errors? I notice the first one appears to be labeled # 49. When you have compilation errors, it is best to start with the first error and work your way down. That way, as you fix your errors and retry the compilation, the odds increase that others may go away as well.

You have several class definitions (clsNoduri, clsReservoir, etc.) that appear to be inheriting from clsElemente, but you haven't specified any inheritance levels. I'm surprised the compiler isn't flagging that.

Post, exactly, what the first error (error # 1) in your error report is. You may have to scroll the output screen up to see it.

Looks like your header file is lacking a '}', the sortWaterNetwork.cpp seems to be OK.

[EDIT]
@Fbody
I think you missed that the OP mentioned "error list excluding the error for other header since the errors are the same", hence #49.

Wow, I post WAAAAY too slow. I think my previous post may be irrelevant by now.

@Fbody: Yes, but that's ok. All those errors where the same and came out from not putting the inlcude stdafx.h first. But now it seems I messed arround with the form header. I will have to solve that issue. Hopefully I'll find the problem soon.

Thank You again guys.

[EDIT]
@Fbody
I think you missed that the OP mentioned "error list excluding the error for other header since the errors are the same", hence #49.

No, didn't miss it, it just seemed to me that there were too many left out. Either that or they weren't as similar as thought. Whatever the case, it got worked out, so it doesn't matter anyway.

@OP:
You need to add a closing/right curly brace near the end of your Form1.h file. Either you deleted it somehow or you opened another sub-block somewhere higher up that you forgot to close properly. Make sure all your braces are properly paired.

@OP
Just a thought, this missing '}' might be due to namespace usage, so

// Begin the namespace
namespace my_namespace {

// code here

} // <- namespace must end with a '}'

I solve it, it was similar to this. When I moved those classes and functions I messedup with those braces. It's all rolling now.

Thank You.

PS: I think it should be made a sticky post with error/solving situations where something weird like this happens. The compiler doesn't explain at all what is happening and therefor You can misjudge the cause.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.