是否可以从记事本等外部文件(或者如果需要也可以使用 cpp 文件)调用例程?
例如,我有 3 个文件。主代码.cpp
SubCode_A.cpp <- 不包含在 MainCode.cpp 的标头中
SubCode_B.cpp <- 不包含在 MainCode.cpp 的标头中
MainCode_A.cpp
#include <iostream>
using namespace std;
int main ()
{
int choice = 0;
cin >> choice;
if (choice == 1)
{
"call routines from SubCode_A.cpp;" <- is there a possible code for this?
}
else if (choice == 2)
{
"call routines from SubCode_B.cpp;" <- is there a possible code for this?
}
return 0;
}
==================================
SubCode_A.cpp 代码
{
if (1) //i need to include if statement :)
cout >> "Hello World!!";
}
==================================
SubCode_B.cpp 代码
{
if (1) //i need to include if statement :)
cout >> "World Hello!!";
}