mercredi 6 juillet 2016

hidden implementation of member function (like static global function)

Let's assume you have two implementation source files with the same content:

// foo{a,b}.cpp
class Foo {
public:
  void bar();
}
void Foo::bar() { std::cout << "bar\n"; }

Implementing a normal function (not a member method), I would simply mark this method as static. But this has a different meaning on method declarations and can not be specified at the implementation.

How can I changed foob.cpp so that there will be no linker errors when both files are being compiled and linked together?

Aucun commentaire:

Enregistrer un commentaire