When to use namespace in C++?

Asked

Viewed 46 times

1

Here’s the thing, since I knew how to use using namespace std; was a bad practice I stopped using namespace. Only now I started studying the Opencv library and see in its documentation to use using namespace cv;. And now I don’t know if I use the using namespace. What are the advantages and disadvantages of using it? Should I use it?

  • 2

    Whenever you read somewhere that a certain feature of a language is "bad practice", stop and reflect if the source where you are reading is that it is not bad. If a resource exists in a language, it is because it is useful in some context. Anything can be turned into bad practice. In fact, I think your question is valid, but it would be better if you focused on something like, "What is the using namespace in C++, what is it for, and when to use it or not?".

  • 2

    Related: http://answall.com/questions/38435/porque-n%C3%a3o-%C3%A9-uma-boa-pr%C3%a1tica-usarmos-namespace-Std-em-c

  • 1

    @Luizvieira I think it is up to duplicate, I see nothing that can be said more than has already been said there in the other, unless he is more specific.

  • @On second thought, I think you’re right. I’m going to vote to close as duplicate.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.