method in different cpp file

Discussion in 'C++' started by carmelo, Feb 26, 2008.

  1. carmelo

    carmelo Guest

    'Hi,I need to use in main.cpp, a method that is defined in
    another .cpp file. How can I do it?
     
    carmelo, Feb 26, 2008
    #1
    1. Advertising

  2. 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.
     
    Gianni Mariani, Feb 26, 2008
    #2
    1. Advertising

  3. carmelo

    Guest

    On 2ÔÂ26ÈÕ, ÏÂÎç8ʱ05·Ö, Gianni Mariani <> wrote:
    > 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.
     
    , Feb 26, 2008
    #3
  4. carmelo

    Guest

    On 26 Feb, 11:22, carmelo <> wrote:
    > '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
     
    , Feb 26, 2008
    #4
  5. carmelo

    nurxb01 Guest

    On Feb 26, 4:22 pm, carmelo <> wrote:
    > '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.
     
    nurxb01, Feb 26, 2008
    #5
  6. wrote:
    > On 2ÔÂ26ÈÕ, ÏÂÎç8ʱ05·Ö, Gianni Mariani <> wrote:
    >> 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.
     
    Gianni Mariani, Feb 26, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DrUg13
    Replies:
    1
    Views:
    478
    DrUg13
    Feb 10, 2004
  2. Shen
    Replies:
    6
    Views:
    9,714
    Patrik Stellmann
    Feb 11, 2004
  3. Alex Vinokur
    Replies:
    7
    Views:
    414
    Greg Comeau
    Nov 15, 2004
  4. Vinu
    Replies:
    9
    Views:
    627
  5. www.hitechskill.com
    Replies:
    0
    Views:
    1,358
    www.hitechskill.com
    Apr 9, 2006
Loading...

Share This Page