I have three files.
file 1
This has the class definition and all the methods in the class are also defined here
file 2
The object of the above class is instantiated here
file 3
Here I want to call one of the methods using the object created in file 2
I am trying to do above thing is because I want the code to be modular. Is there a better way to do this? Can you post any other solution that you may have?
Put your definition into an header file (usually .h):
Include definition and implement it in another file (usualy .cpp)
Then include the header with the definitions where you want to use
Remember that the 2 translation units must be linked together.