C++とヘッダ
まず cpp_test.h
//堀越 CPP; p.460 #ifndef CPP_TEST #define CPP_TEST #include <iostream> #include <vector> using namespace std; class Xvec { public: vector <int> vec; public: Xvec (); Xvec (vector <int> argvec); void showVec(); void putVec(int i); }; #endif
cpp_test.cpp
//#include <iostream> //#include <vector> #include "cpp_test.h" using namespace std; Xvec::Xvec(){ } Xvec::Xvec(vector<int> argvec){ vec = argvec; } void Xvec::showVec(){ cout << vec.size() << endl;; } void Xvec::putVec(int i){ vec.push_back(i); }
cpp_test_main.cpp
#include "cpp_test.h" int main(){ Xvec x; for(int i = 0; i < 8; i++){ x.putVec(i); } x.showVec(); return 0; }
添付ファイル:
cpp_test_main.cpp 596件
[詳細]
cpp_test.h 603件
[詳細]
cpp_test.cpp 634件
[詳細]



Last-modified: 2008-01-27 (日) 15:40:38 (6270d)