User Tools

Site Tools


programming:cpp:binary

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
programming:cpp:binary [2022/04/12 08:21]
odagawa
programming:cpp:binary [2022/04/30 17:48] (current)
odagawa
Line 4: Line 4:
 テキスト入出力するよりバイナリ入出力したほうがファイルサイズが小さくなるので使った.\\ テキスト入出力するよりバイナリ入出力したほうがファイルサイズが小さくなるので使った.\\
 ROOT を使っている限りは気にする必要がないが, emulsion とのデータをやり取りするために必要だった. ROOT を使っている限りは気にする必要がないが, emulsion とのデータをやり取りするために必要だった.
 +
 +このとき,vector のような可変長配列は要素数を保持しておく必要がある.\\
 +したがって,''ReadMyClassHeader/WriteMyClassHeader'' という関数を作成し,\\
 +単なるメンバ変数とともに vector の要素数を追加で読み書きできるようにしておくことがポイントだと思う.
  
 たとえば以下のようなクラスを考える. たとえば以下のようなクラスを考える.
  
 <code cpp MyClass.hpp> <code cpp MyClass.hpp>
 +#ifndef MYCLASS_HPP
 +#define MYCLASS_HPP
 +
 #include <vector> #include <vector>
  
Line 16: Line 23:
   std::vector<double> vec;   std::vector<double> vec;
 }; };
 +#endif
 </code> </code>
  
programming/cpp/binary.1649751683.txt.gz · Last modified: 2022/04/12 08:21 by odagawa