method in different cpp file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • carmelo

    method in different cpp file

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

    #2
    Re: method in different cpp file

    carmelo wrote:
    '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.

    Comment

    • zhangyw80@yahoo.com.cn

      #3
      Re: method in different cpp file

      On 2ÔÂ26ÈÕ, ÏÂÎç8ʱ05·Ö, Gianni Mariani <gi4nos...@mari ani.wswrote:
      carmelo wrote:
      '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.
      you can put the declaratin of this method to the beginning of
      the .cpp file where you call this method.

      Comment

      • keith@bytebrothers.co.uk

        #4
        Re: method in different cpp file

        On 26 Feb, 11:22, carmelo <carmelo.abr... @gmail.comwrote :
        'Hi,I need to use in main.cpp, a method that is defined in
        another .cpp file. How can I do it?
        In addition to the responses you've had, I would add that if (and you
        don't state, so I don't know) your question relates to templates, you
        might want to check out the FAQ at http://www.parashift.com/c++-faq-lite/templates.html

        Comment

        • nurxb01

          #5
          Re: method in different cpp file

          On Feb 26, 4:22 pm, carmelo <carmelo.abr... @gmail.comwrote :
          '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.

          Comment

          • Gianni Mariani

            #6
            Re: method in different cpp file

            zhangyw80@yahoo .com.cn wrote:
            On 2ÔÂ26ÈÕ, ÏÂÎç8ʱ05·Ö, Gianni Mariani <gi4nos...@mari ani.wswrote:
            >carmelo wrote:
            >>'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.
            >
            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.

            Comment

            Working...