views:

220

answers:

4

In C++ I have a file A.cpp that has the following in it:

 namespace Foo {

     bool Bar() 
     { 
         return true; 
     }

 }

How would I declare this function in A.h? How do I handle the namespace?

+5  A: 
namespace Foo {
  bool Bar();
}
John Dibling
+5  A: 
namespace Foo {
    bool Bar();
}
sharptooth
+1 for being character for character the same as John Dibling's answer with the same time stamp (rounded to the minute)
Jamie Cook
+2  A: 
namespace Foo {
    bool Bar();
}

Or

namespace Foo;
bool Foo::Bar();
maccullt
You can use namespace Foo {} to wrap declarations and definitions in as many places as you want. It basically adds "Foo::" to the front of the name of everything inside the brackets. Things not inside a namespace that you name are in the default global namespace.
UncleO
Nice second example. I'd never considered that approach.
Shmoopty
+1  A: 
namespace Foo {
    bool Bar();
}
Suvesh Pratapa