(抱歉英文不好) 嗨,大家好 ! 我的程序不想运行因为错误,谢谢你帮助我。
我的来源:
的main.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <string>
#include <vector>
#include "function_h.h"
using namespace std;
int main()
{
int reponse(0);
ifstream myfile("dico.txt");
cout << "1. Mode solo | 2. Mode multi" << endl;
cout << "> ";
cin >> reponse;
if (reponse > 0 || reponse < 3)
{
cin.ignore();
if (reponse == 1)
{
}
} else { cout << "Une reponse valide." << endl; }
}
function.cpp
#include "main.cpp"
#include "function_h.h"
using namespace std;
string Melange(string mot)
{
int position(0);
string result;
while (mot.size() != 0)
{
result += mot[position];
mot.erase(position, 1);
}
return result;
}
function_h.h
#ifndef FUNCTION_H_H_INCLUDED
#define FUNCTION_H_H_INCLUDED
using namespace std;
string Melange(string mot);
#endif
感谢&#39; S
答案 0 :(得分:2)
问题在于:
#include "main.cpp"
通常,您不希望(需要)在任何地方包含.cpp
个文件(编译单元)(除非您想要包含外部模板类定义)!