/* Application File */ #include "libPrintMe.h" int main (void) { char *myMainString; kellyClass testClass; myMainString = "world"; testClass.printMe(myMainString); }; /* Public Header File */ class kellyClass { public: int printMe (char *myString); }; /* Library File */ #include <iostream> #include "libPrintMe.h" using namespace std; /* Pulls in the standard c++ library above #include <iostream> */ int kellyClass::printMe (char *myString) { cout << "hello " << myString << "\n"; return 0; }; #!/bin/bash # build file echo "build libPrintme.a" g++ -c libPrintMe.cc -o libPrintMe.a echo "bild printMe" g++ printMe.c -o printMe -I. libPrintMe.a |
Same code as before with a bit more C++friendly code.
No comments:
Post a Comment