C++メモ

「C++メモ」の編集履歴(バックアップ)一覧に戻る

C++メモ - (2011/09/21 (水) 06:54:18) のソース

Windows上でのC++入門
http://keicode.com/winprimer/

構造体の配列を引数として関数に渡す方法

http://hitorilife.com/struct.php


void型変数の受け渡し

Assume that you want to pass two arrays, one of doubles and one of integers. A quick but not very elegant solution is to use global variables. The simplest way to avoid using globals is to declare a structure as

struct mydata{
   double dar[XXX];
   int iar[YYY];
};

where XXX and YYY denote the appropriate array sizes. Then, define a structure variable with

struct mydata data;

and fill it:

data.dar[0]=7.0;
data.iar[0]=-17;
// etc

Following this, call the appropriate LM routine passing it the address of data as the adata argument, e.g.

ret=dlevmar_der(func, fjac, ..., (void *)&data);

Your func and fjac routines should interpret the supplied data using type casting:

struct mydata *dptr;

dptr=(struct mydata *)adata; // adata is passed as void *


オブジェクトの参照渡し
http://wisdom.sakura.ne.jp/programming/cpp/cpp12.html

フレンドクラス

http://www.geocities.jp/ky_webid/cpp/language/022.html

コピーコンストラクタ
http://www.geocities.jp/ky_webid/cpp/language/016.html

内部クラス
http://www.geocities.jp/ky_webid/cpp/language/030.html

オブジェクト配列
http://ppwww.phys.sci.kobe-u.ac.jp/~akusumoto/program/detail.php?d=c/05-pointer/pointer_array

Link
http://www.sat.t.u-tokyo.ac.jp/~tetsuya/homeNew/research/Tips/cpp_for_researcher_1.htm

N-body sample program
http://www.cs.cmu.edu/~ph/859E/src/nbody/nbody.html