I need to use private variable of a class inside a C function. I was doing something like this
class Helper
{
private:
std::string name;
public:
std::getName(){return name;}
friend extern "C" void initializeHelper();
};
but this code segment gives error unqualified-id before string constant
extern "C" {
I am not able to identify what I am doing wrong here.
Just forward-declare this function before your class:
extern "C" void foo();
Then you can use it in friend-declaration:
class A {
public:
A() {}
private:
friend void foo();
int a;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With