Friend fumction in C++ class
// in the header file void changeVar(); // define it. class testFriend { friend void changeVar(); // declare it private: int m_i; } // in the cpp file void changeVar( testFriend&i ) // implement it { i.m_i++; } // in the main file int main() { testFriend test; changeVar(test); }
Comments
Post a Comment