//lib.cpp #include "lib.h" class myclass { public : int value; }; myclass m1;
//lib.h #ifndef LIB_H_INCLUDED #define LIB_H_INCLUDED class myclass; extern myclass m1; #endif // LIB_H_INCLUDED
#include <iostream> #include "lib.h" using namespace std; int main() { m1.value=10; cout<<m1.value; return 0; }
#include <iostream> #include "lib.h" using namespace std; extern myclass m1; int main() { m1.value=10; cout<<m1.value; return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)