-
March 27th, 2009, 10:22 PM
#1
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
-
March 27th, 2009, 11:40 PM
#2
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.
-
March 28th, 2009, 12:55 AM
#3
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
-
March 28th, 2009, 05:05 AM
#4
Re: Need help in calling function
Syntax of calling a non-static member function is
object.Function(params)
-
March 28th, 2009, 09:46 AM
#5
Re: Need help in calling function
Originally Posted by Mybowlcut
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|