C++对main的多重定义
C++ Multiple definition of main
(抱歉英语不好)嗨,伙计们!我的程序不想运行,因为一个错误,谢谢你好心帮助我。
我的来源:
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; }
}
函数.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;
}
函数_h.h
#ifndef FUNCTION_H_H_INCLUDED
#define FUNCTION_H_H_INCLUDED
using namespace std;
string Melange(string mot);
#endif
错误
感谢
问题就在这里:
#include "main.cpp"
通常,您不希望(需要)在任何地方包含.cpp
文件(编译单元)(除非您希望包含外部模板类定义)!
相关文章:
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- File.cpp.o:OpenPose 标志 CMakeFiles/.. 的多重定义/main.cpp.o:首先在这里定
- C++:main() 未捕获的异常的自定义格式
- C++/生成文件错误:未定义对"main"的引用
- 在命名空间中声明变量,在 main 中定义它,使其对所有其他文件可见
- 可视化 如何修复 c++ 中已经定义的 -main?
- 在 Linux 上编译 - 在函数 '_start' 中:(.text+0x20):对 'main' 的未定义引用
- C++错误:在类中取消对main的定义引用
- crt1.o:在函数"_start"中:(.text+0x20):对"main"的未定义引用
- Main.Obj中已经定义的主要
- main.cpp:(.text+0x8ea):在C++中未定义的引用
- 实用程序函数不会在 .h 文件中初始化并在 main 中定义.cpp
- C :使用Main中定义的对象方法的函数
- 已在main.obj中定义了双精度
- C++ 编译错误:- 使用Makefile对"main"进行多重定义
- C++编译错误:多个定义"main",但项目中只有一个 main 函数
- 你能定义 main() 来接受不仅仅是 argc/argv 参数吗?
- 谷歌基准自定义main
- 实现自定义Main函数
- 在类中定义main函数