【发布时间】:2017-10-10 04:06:46
【问题描述】:
我是 C++ 语言的新手。 所以我被分配将一个现有文件拆分成三个源代码:swap.h、swap.cpp 和 source3.cpp
现有文件:
#include <iostream>
void get_numbers (int&, int&);
void swap_values (int&, int&);
void show_results (int, int);
int main () {
int first_num, second_num;
get_numbers (first_num, second_num);
swap_values (first_num, second_num);
show_results (first_num, second_num);
return 0;
}
void get_numbers (int& input1, int& input2) {
using namespace std;
cout << "Enter two integers: ";
cin >> input1 >> input2;
}
void swap_values (int& variable1, int& variable2) {
int temp;
temp = variable1;
variable1 = variable2;
variable2 = temp;
}
void show_results (int output1, int output2) {
using namespace std;
cout << "In reverse order the numbers are: "
<< output1 << " " << output2 << endl;
}
swap.h 包含函数原型
swap.cpp 包含函数实现
source3.cpp 包含主函数
对于swap.h:
#pragma once
#ifndef swap_h
#define swap_h
void get_numbers(int&, int&);
void swap_values(int&, int&);
void show_results(int, int);
#endif
对于swap.cpp
#include <iostream>
void get_numbers(int& input1, int& input2) {
using namespace std;
cout << "Enter two integers: ";
cin >> input1 >> input2;
}
void swap_values(int& variable1, int& variable2) {
int temp;
temp = variable1;
variable1 = variable2;
variable2 = temp;
}
void show_results(int output1, int output2) {
using namespace std;
cout << "In reverse order the numbers are: "
<< output1 << " " << output2 << endl;
}
对于 source3.cpp:
#include "stdafx.h"
#include "swap.h"
int main()
{
int first_num, second_num;
get_numbers(first_num, second_num);
swap_values(first_num, second_num);
show_results(first_num, second_num);
return 0;
}
当我调试程序时,它说:“无法启动程序'C:\用户......' 该系统找不到指定的文件。我做错了什么?
【问题讨论】:
-
哪个文件?发布该路径的结尾部分..
-
这将很难重现。它为我编译,必须删除 Visual Studio-isms,因为我目前无法访问 MSVC,并且似乎以我期望的方式运行和运行。编辑您的问题并粘贴到输出窗口的内容中。也许有人会看到一些不寻常的东西并提供有用的建议。
标签: c++ visual-c++