CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    19

    Need help in calling function

    I have this header file

    Code:
    #ifndef DRAWTRACK_H
    #define DRAWTRACK_H
    
    
    class VectorDraw
    {
     private:
     int x , y ;
    
     public:
     void FastRect();
    };
    
    #endif
    And I have a function delaration in another file



    Code:
    #include <iostream.h>
    #include "drawtrack.h"
    
    void VectorDraw::FastRect()
    {
    cout<<"some random code here";
    
    }

    I want to call this function from another file .
    Can someone tell me the syntax

  2. #2
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: Need help in calling function

    How did you get this far without knowing how to call a member function? I'm not sure I quite understand why you wouldn't know, but all you have to do is #include the header file (drawtrack.h), create a VectorDraw object and call the function.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  3. #3
    Join Date
    Jan 2009
    Location
    Salt Lake City, Utah
    Posts
    82

    Re: Need help in calling function

    Code:
    int main(blah)
    {
        VectorDraw obj;
        obj.FastRect();
    }
    Intel Core Duo Macbook w/ Mac OS 10.5.6
    gcc 4.2.1 (i386-apple-darwin9.1.0) and Xcode 3.1.1

  4. #4
    Join Date
    Oct 2008
    Location
    Singapore
    Posts
    195

    Re: Need help in calling function

    Syntax of calling a non-static member function is
    object.Function(params)

  5. #5
    Join Date
    Jan 2009
    Posts
    19

    Re: Need help in calling function

    Quote Originally Posted by Mybowlcut View Post
    How did you get this far without knowing how to call a member function? I'm not sure I quite understand why you wouldn't know, but all you have to do is #include the header file (drawtrack.h), create a VectorDraw object and call the function.
    Actually I know how to create an object and call the function . The thing was I was traeting those files as an empty file . I hadn't stored it in some project . Those files were all over the plcaes and when I was trying to call it . It was snot getting called.

    Srry for wasting your precious time . It's been a long day and now I'm going to sleep

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured