I have a C++ class that has a function "Connect()" which calls another function I wrote in straight C, also called Connect.
My question is, how can I call the second in the first without the names clashing?
I have a C++ class that has a function "Connect()" which calls another function I wrote in straight C, also called Connect.
My question is, how can I call the second in the first without the names clashing?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
If the C function is a member of another namespace then all you have to do is use the scope resolution operator with the namespace:
namespace :: Connect();
If you aren't using namespaces and the function is global, then you can do something like this:
This code will printCode:#include <iostream> using std::cout; void func ( void ) { cout<<"global\n"; } class test { public: void func ( void ); }; void test::func ( void ) { cout<<"local to test\n"; ::func(); // Global namespace } int main ( void ) { test t; t.func(); return 0; }
local to test
global
-Prelude
My best code is written with the delete key.
Thanks Prelude!
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }