标签:.cpp invalid bsp initial which man end eve name
1 // test1.h 2 int a = 10; 3 struct AA 4 { 5 int a,b: 6 };
AA b(5,6); 7 int ball();
1 // test1.cpp 2 # include"test1.h" 3 4 // the following line is invalid for it will not executed( if it‘s initialization of a var, it‘s valid) 5 // a = 11; 6 7 int ball() 8 { 9 a =13; 10 b = AA(3,4); 11 return a+4; 12 }
build a lib with command line : g++ -fPIC -shared test1.cpp -o libtt.so
# include<iostream> using namespace std; extern int a; extern int b; int ball(); int main() { cout << " call ball() " << ball() <<endl; cout << "value of a " << a <<endl; cout << "value of b" << b << endl; }
to build an executable with command line: g++ test-main.cpp -L./ -ltt
Notice:
标签:.cpp invalid bsp initial which man end eve name
原文地址:http://www.cnblogs.com/resibe-3/p/6537285.html