c++ - Calling member functions of a class object which is present in header file included -
i new forum wanted call member function of included header file..here code have written
#include<stdio.h> #include "abc.h" cabc *a;//cabc class present in abc.h int main(int argc,char **argv) { int i=10; float j=15.5; bool x; x=a->method(i,j);//method member function of cabc if(x) { printf("working correctly"); } else { printf("not working"); }
}
if compile using
g++ -i/path/to/include code.cpp
i error
/tmp/cc5jglff.o: in function `main': code.cpp:(.text+0x3d): undefined reference `cabc::method(int,float)' collect2: ld returned 1 exit status
i tried giving
x=a::method(i,j);
for not class or namespace
please can tell me doing correctly or not?
it looks though forgetting include implementation source/object.
try this:
g++ -i/path/to/include abc.cpp code.cpp
as long implementation class abc.h corresponds abc.cpp.
regards,
dennis m.
Comments
Post a Comment