0
私は、補足的な追加ソースコードファイル(異なる人が多少異なる機能を追加する可能性がある)に応じて、異なる動作をするプログラムを作成します。ソースコードファイルセットに応じたC++プログラムの動作
file1.cpp:
#include <iostream>
#include <string.h>
using namespace std;
class base {
public:
void ausgeb() { cout<<"here output base"<<endl; }
};
class derive: public base;
int main(int argc, char** argv)
{
derive beisp;
beisp.ausgeb();
}
file2.cpp:今、私はそれを望んだ
#include <iostream>
#include <string.h>
using namespace std;
class base;
class derive : public base
{
public:
void ausgeb() { cout<<"here output derive"<<endl; }
};
:
私は(非コンパイル)次のコードに似た関数のオーバーロード、考えましたg++ -o o1 file1.cpp file2.cpp
および
g++ -o o2 file1.cpp
は、出力が異なる実行可能ファイルを生成する必要があります。 その必要性を満たす可能性がありますか?
'file2.cpp'では、コンストラクタが[pimpl](https://en.wikipedia.org/wiki/Opaque_pointer#C)を使って' derive'の実装を切り替えるオブジェクトをファイルスコープに持つことができます。 2B.2B)イディオム。 –