I have a Class
named MyClass
and I have a function that is defined as public, I'm trying to call this function from another file that has a main
function int main(int argc, char *argv[])
MyClass.h:
class MyClass:
{
public:
MyClass();
~MyClass();
PerformOperation(int*, int);
}
MyClass.c
void MyClass::PerformOperation(int* myarr, int number)
{
//Do something
}
myMainprog.c
int main(int argc, char *argv[])
{
MyClass obj;
int* myArr = {1,4,7,0,2};
int num = 5;
obj->(myArr, num);
}
When I compile my code I get:
Undefined symbols for architecture x86_64:
MyClass::PerformOperation(int* myarr, int number), referenced from: _main in ccUbOgEv.o
ld: symbol(s) not found for architecture x86_64
I'm running my code on OSX 10.9.4
using g++
.
And my problem is not that I did not specify all the files as it is here.
The code works perfectly on linux.