Is access specifier used in c++ function signature?

Thai Xuan Thien (RBVH/EPS43) 21 Reputation points
2020-07-30T15:18:39.96+00:00

Hi all,
I'm having an issue when try to access private member function like this:

/*source.cpp*/
class TEMP{
private:
    void funcNeedToTest(); //this function has private access specifier
};

void TEMP::funcNeedToTest(){
//do something
}

and in test script, I change the access specifier of private member function funcNeedToTest() to public:

/*testScript.cpp*/
class TEMP{
public:
    void funcNeedToTest(); //in test script, I think I can access to funcNeedToTest() from outside class TEMP :)
};

void main(){
    TEMP obj;
    obj.funcNeedToTest();
    return 0;
}

But with MSVC, the linker has reported an error: error LNK2019: unresolved external symbol "public: void __thiscall TEMP::funcNeedToTest(void)" referenced in function _main
This issue has not happened with GCC. So is there any option from MSVC to ignore access specifier in signature ?
Thank you!

Community Center | Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2020-07-30T15:25:22.307+00:00

    C++ is not currently supported here on QnA. They're actively answering question in dedicated forums here.
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral
    https://developercommunity.visualstudio.com/spaces/62/index.html

    --please don't forget to Accept as answer if the reply is helpful--


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.