通知
すべてクリア
Topic starter
2003年10月30日 3:36 PM
環境ですが、WinNT、VC++6.0になります。
やりたいことは、
A構造体
static A{
CString str;
};
の宣言をしておいて、
A astr[3]={あいう,エオ,可};
のように、一度に入れたいです。
別々に入れるとこまではできました。
astr[0]=あいう;
astr[1]=エオ;
・
・
いろいろ調べているのですが、
静的変数?や、static?や、malloc?みたいなのがでてきました。
調べ方だけでも教えていただければ幸いです。
2003年10月30日 3:54 PM
#include <afx.h>
#include <iostream>
struct A {
CString str;
A(const char* s) : str(s) {} // これがミソ
};
int main() {
A aa[] = { zero, one, two };
for ( int i = 0; i < 3; ++i ) {
std::cout << static_cast<const char*>(aa[i].str) << std::endl;
}
return 0;
}
Topic starter
2003年10月30日 4:39 PM
ありがとうございます!
早速ためしてみます。
あとは、自分でなんとかなるかと思うので、解決します。