1
SFML projects / Re: Simple Fast SFML Physics
« on: June 30, 2022, 07:19:18 pm »
There's one thing you should never do when making a C++ library, and that is putting "using namespace std;" globally in a public header.
The reason is that a you're forcing "using namespace std;" to anyone who uses your library, and lot of people don't like having "using namespace std;" in their code.
So be considerate to your users and don't force that on them.
Fortunately there's a quick and dirty way to alleviate this issue, and that is to simply put the using directives inside your namespace.
This isn't ideal (personally I wouldn't put using directives in headers files) but it is a minimum standard that is really quick to achieve.
The reason is that a you're forcing "using namespace std;" to anyone who uses your library, and lot of people don't like having "using namespace std;" in their code.
So be considerate to your users and don't force that on them.
Fortunately there's a quick and dirty way to alleviate this issue, and that is to simply put the using directives inside your namespace.
Code: [Select]
namespace sfp {
//This is now inside your namespace sfp
using namespace std;
using namespace sf;
This isn't ideal (personally I wouldn't put using directives in headers files) but it is a minimum standard that is really quick to achieve.