|
-
March 6th, 2003, 08:21 AM
#1
STL error - with declaration move to other .h file, please help.
In .cpp file I write:
Code:
#include "file.h"
#include <map>;
using namespace std;
class CPartHolder;
typedef map<int,CPartHolder*> type_MapPartHolder;
type_MapPartHolder mapPartHolder;
class CPartHolder
{
};
works fine
but if I move or add
declarations:
file.h :
Code:
#include <map>;
using namespace std;
into .h file
appeared STL error
"operator new not defined for...."
What is the reason of this and gow to resolve
such a problem?
Thanks
Last edited by vgrigor3; March 6th, 2003 at 12:10 PM.
-
March 6th, 2003, 09:04 AM
#2
Well I don't know much about C++ or STL ... basically just what people have taught me here. But I do know that you aren't suppose to have a "using namespace ..." in a header file. Instead write a "using" for each command you use, in your case "using std::map".
Also did you include the .h in the .cpp?
-
March 6th, 2003, 09:10 AM
#3
-
March 6th, 2003, 10:09 AM
#4
In a header file, you should not use "using namespace std;", since otherwise all files which include this header will become "polluted" with the std namespace. But this seems not to be the problem here. Can you post a short succint, but compilable version of your .cpp and .h files that exhibit the problem ?
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
March 6th, 2003, 11:54 AM
#5
When you moved the statements to the .h file, did you include that .h in the original .cpp?
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
-- Sutter and Alexandrescu, C++ Coding Standards
Programs must be written for people to read, and only incidentally for machines to execute.
-- Harold Abelson and Gerald Jay Sussman
The cheapest, fastest and most reliable components of a computer system are those that aren't there.
-- Gordon Bell
-
March 6th, 2003, 12:08 PM
#6
I included .h file to the .cpp.
But I made it working by only making additional separate .h file
for map processing class and map definition.
reason for original error still not found by me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|