Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BB-Pest

using namespace std -- getting compiler errors

This topic is 5801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i tried to use this command but when i try to compile i get errors in ostream.h (cant name the english error but its something about elements having several meanings) what am i doing wrong? btw: i have several .cpps each including an includes.h which includes all the other .h s. when i remove all '#include includes.h' i only get other compiler errors resulting out of not having information about the classes. [edit1] im using std since my compiler does not seem to recognize the list<> class if i do not use std::list<> in the implementation [edited by - BB-Pest on December 4, 2002 3:39:10 PM]

Share this post


Link to post
Share on other sites
Advertisement
i dont get the errot by including ... just by adding the line

'using namespace std;'

but perhaps the fault lies somewhere else... here's a part of the code:


    
#ifndef INVENTORY_H
#define INVENTORY_H

#include <'vector'> //without the ''
#include "Items.h"


// ...


/////////////////////////////////////////////////////////////////////////////

// Inventory


class Inventory
{
// ...

vector<InvNode> itemList;
// ...

};

#endif



but the compiler does not recognize vector.

[edited by - BB-Pest on December 4, 2002 3:51:05 PM]

Share this post


Link to post
Share on other sites
In headers, it''s preferrable not to use the using namespace std (or any other namespace) directive because of namespace pollution issues. In your case, the code sample your provided neither uses namespace standard nor does it fully specify std::vector:

  
#include <vector>

#include "Items.h"

class Inventory
{
std::vector<InvNode> itemList;
};

Share this post


Link to post
Share on other sites
thanks... both solutions worked.

now: is there any way to make my visual studio use the code-completing function. typing ''itemList.'' will not make the possible elements pop-up( neither for itemList[]. (should i use iterator instead btw?)).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!