c++ - Calling an "external" function from a class method -
i have function want call within class method. function in file called mergesort.cpp. here snippet of .cpp file class implemented in:
// other includes #include "mergesort.cpp"  // other methods void servers::sortsites() {  mergesort(server_sites.begin(), server_sites.end(), sitecompare); } // remaining methods  when try compile errors saying mergesort can't found. think because it's trying call servers::mergesort. how go calling external function?
you have use "::" external namespace resolutor:
::mergesort(...); this tells compiler function in outer namespace. if particular function defined in namespace or class, have specify explicitly:
namespace::mergesort(...); if don't want have resolve name each time use it, can import name current namespace either using:
using namespace namespace; or
using namespace::mergesort; (where namespace name in mergeshort() defined).
Comments
Post a Comment