method in different cpp file

C

carmelo

'Hi,I need to use in main.cpp, a method that is defined in
another .cpp file. How can I do it?
 
G

Gianni Mariani

carmelo said:
'Hi,I need to use in main.cpp, a method that is defined in
another .cpp file. How can I do it?

See some docs on how #include directives are used.
 
Z

zhangyw80

See some docs on how #include directives are used.

you can put the declaratin of this method to the beginning of
the .cpp file where you call this method.
 
N

nurxb01

'Hi,I need to use in main.cpp, a method that is defined in
another .cpp file. How can I do it?


You can use header file , source file approche.
Declare the function in the header file and provide the defination in
the source file.
Include this header file using #include statement in the main.cpp.
 
G

Gianni Mariani

you can put the declaratin of this method to the beginning of
the .cpp file where you call this method.

Sure, but in practice it is done with header files and pointing him in
the header file direction will prolly give him the best chance of
getting it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top