昔作った C++ プログラム1を引っ張りだして来たら、コンパイルできない(苦笑)。 C++ ってそういうプログラミング言語だと、2000年頃痛感したけれど、 その頃作ったプログラムも今はコンパイルできない。 C ではあり得ないことだけど、 C++ では、それが許される環境にあるので、 新しい機能が取り込める、ということなのかな?
| #include <iostream.h> #include <complex.h> | 
| #include <iostream> #include <complex> | 
| using namespace std; | 
自動的に処理することも出来て、 例えば Michel and Stoitsov [1] の hyp_2F1 の complex_functions.H では、 それにオペレーター・オーバーロードで対応している。
| complex_functions.H から引用 | 
| // Usual operator overloads of complex numbers with integers // --------------------------------------------------------- // Recent complex libraries do not accept for example z+n or z==n with n integer, signed or unsigned. // The operator overload is done here, by simply putting a cast on double to the integer. | 
| 
inline complex<double> operator + (const complex<double> &z,const int n)
{
  return (z+static_cast<double> (n));
}
 | 
| 
extern void     g_init G_ARGS ((char * file_name, G_P_DIM win_width,
                                G_P_DIM win_height));
 | 
| 
extern void     g_init G_ARGS ((const char * file_name, G_P_DIM	win_width,
                                G_P_DIM win_height));
 | 
| 
  g_init("DKGRAPH", 120.0, 120.0);
 | 
| g_init((char *)"DKGRAPH", 120.0, 120.0); |