用VS2010编写jiqr6.cpp程序
解决方案资源管理器:头文件侠下添加ho.h,源文件侠下添加jiqr6.cpp与ho.cpp.
//ho头文件
#ifndef HO_H // 防止头文件重复包含
#define HO_H
void max(int a,int b); // 函数声明
#endif
/*************************/
//ho.cpp原文件
#include "ho.h" // 包含头文件以获取类声明
void max(int a,int b) {
if (a>b) a=100;// 函数体实现...
else a=200;
}
/************************/
//jiqr6.cpp主函数调用max函数
#include "ho.h" // 包含自定义头文件
//#include <iostream>
//using namespace std;
int main() {
max(0, 8);// 调用max.cpp中的函数
return 0;
}
/***********************/
用VS2010调试jiqr6.cpp,生成失败。
解决方案资源管理器:头文件侠下添加ho.h,源文件侠下添加jiqr6.cpp与ho.cpp.
//ho头文件
#ifndef HO_H // 防止头文件重复包含
#define HO_H
void max(int a,int b); // 函数声明
#endif
/*************************/
//ho.cpp原文件
#include "ho.h" // 包含头文件以获取类声明
void max(int a,int b) {
if (a>b) a=100;// 函数体实现...
else a=200;
}
/************************/
//jiqr6.cpp主函数调用max函数
#include "ho.h" // 包含自定义头文件
//#include <iostream>
//using namespace std;
int main() {
max(0, 8);// 调用max.cpp中的函数
return 0;
}
/***********************/
用VS2010调试jiqr6.cpp,生成失败。