titanandrews
Programmer
Hi,
I am new to C++ so please bare with me. I have a member function prototype in the header file which is private. I will call it priv_A. Then I have the implementation of that function in the cpp file. (I understand this is the 'normal' way to do it... Someone please correct me if I'm wrong) I also have another member function which is public that calls this private function. I will call it pub_B.
Okay, so my cpp file compiles/links fine. No problem.
So now I want to call this object from another program which is in another cpp file and use pub_B. However on the link step I get a complaint about the priv_A function which is private. I thought that maybe if I use extern on priv_B, compiler would know that it's definition is in another file, but instead I get errors when compiling.
Can someone please clarify the use of extern and what the correct way of implementing this is? Many thanks to you!
Barry
I am new to C++ so please bare with me. I have a member function prototype in the header file which is private. I will call it priv_A. Then I have the implementation of that function in the cpp file. (I understand this is the 'normal' way to do it... Someone please correct me if I'm wrong) I also have another member function which is public that calls this private function. I will call it pub_B.
Okay, so my cpp file compiles/links fine. No problem.
So now I want to call this object from another program which is in another cpp file and use pub_B. However on the link step I get a complaint about the priv_A function which is private. I thought that maybe if I use extern on priv_B, compiler would know that it's definition is in another file, but instead I get errors when compiling.
Can someone please clarify the use of extern and what the correct way of implementing this is? Many thanks to you!
Barry