注册 登录
编程论坛 C++教室

关于C++编程中如何把第二个文件包含在第一个文件中

丘汤媚 发布于 2014-02-25 20:25, 593 次点击
file1.1
#include<iostream>
#include"file1.2"
using namespace std;
int main()
{int num1,num2;
 bool divides(int,int);
 cin>>num1>>num2;
 cout<<divides(num1,num2)<<endl;
 return 0;
}
file1.2
#include<iostream>
using namespace std;
bool divides(int n,int m)
{
    if(m==0)
        cout<<"参数出错"<<endl;
     else if(n%m==0)
         return true;
     else return false;
}
为什么VC6.0说no compile tool is associated with the file extension.
4 回复
#2
fxbszj2014-02-25 21:28
程序代码:
file1.1
#include<iostream>
#include"file1.2"
using namespace std;
int main()
{int num1,num2;
bool divides(int,int);
cin>>num1>>num2;
cout<<divides(num1,num2)<<endl;
return 0;
}


file1.2
//#include<iostream>
//using namespace std;
bool divides(int n,int m)
{
    if(m==0)
        std::cout<<"参数出错"<<std::endl;
     else if(n%m==0)
         return true;
     else return false;
}
#3
丘汤媚2014-02-26 19:59
不能编译。
#4
天使梦魔2014-02-26 20:51
no compile tool is associated with the file extension.
没有编译工具与文件扩展名关联。


编译器不是随便读取H,或者CPP文件的
要么定义*.2文件的关联,要么改文件类型
还有H文件类型默认不编译,CPP默认以单元模块编译
比如在一个CPP里添加一个CPP
#include "*.cpp"
而这个被链接进来的CPP一定要把编译它取消掉,也就是选择为“不编译只是加入”(VC6我不知道怎么做的,只是理论是这个,一般有对每个CPP进行配置的选项)
如果不取消单元编译则编译器会提示重复编译一个模块
#5
fxbszj2014-02-27 07:47
回复 3楼 丘汤媚
换个编译器,vc6.0太老了
1