0

In a header file, should I prototype functions using the full namespace::type or bring the type into scope with using namespace::type?

#pragma once
...
void m_print(std::string msg);

vs

#pragma once
...
using std::string;
void m_print(string msg);
Brady Dean
  • 3,378
  • 5
  • 24
  • 50
  • 4
    No. That `using` will leak into every other file that includes your header. – AndyG Oct 03 '16 at 20:53
  • 1
    Opinion-based questions are off topic on SO. I'd prefer the former though, as you should always minimize your impacts on other files which import your headers. – tkausl Oct 03 '16 at 20:55
  • here is what the [C++ Core guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rs-using-directive) has to say about using in headers. – RedX Oct 03 '16 at 20:55

0 Answers0