const、static、externがヘッダファイルにあるような場合のまとめ
1263 ワード
const C言語ではconst修飾の変数に静的領域があり,c++にはメモリを占めないコード領域がある.ヘッダファイルで定義
static//スタティック領域に格納ヘッダファイルで定義
extern//グローバル変数静的領域ヘッダファイルに格納定義{{extern//グローバル変数:スタティック領域に格納}}
//test.h
ヘッダファイルのクラスで使用
//test.h
#ifndef _TEST_H_
#define _TEST_H_
const int a = 0;// , , test.h const int a=0;
#endif
static//スタティック領域に格納ヘッダファイルで定義
//test.h
#ifndef _TEST_H_
#define _TEST_H_
static int a = 1;// , , test.h static int a=1;
#endif
extern//グローバル変数静的領域ヘッダファイルに格納定義{{extern//グローバル変数:スタティック領域に格納}}
//test.h
#ifndef _TEST_H_
#define _TEST_H_
extern int a;// , , test.h extern int a; //
// ".c" int a; , extern 。 int a; a 。
// 。
extern int a=0;// , int a = 0, //
#endif
ヘッダファイルのクラスで使用
#ifndef TEST_H
#define TEST_H
class test
{
public:
const static int a=10;// cout<<<:a static="" int="" a="" extern="" test::a="" cout="" public:="" test="" virtual="" protected:="" private:="" test_h=""/>