C++とヘッダ - アールメカブ

アールメカブ


C++とヘッダ

Programming

まず 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;
}
 
添付ファイル: filecpp_test_main.cpp 494件 [詳細] filecpp_test.h 490件 [詳細] filecpp_test.cpp 522件 [詳細]
 
Link: Programming(4985d) Programming_C(5436d) 日録2008_1月(5929d)
Last-modified: 2008-01-27 (日) 15:40:38 (5934d)