Hallo,
ich bin gerade dabei, das Buch zu lesen. Dabei habe ich versucht, ein Beispielprogramm zu erstellen und in verschiedene Dateien aufzuteilen. Jedoch bekomme ich immer wieder den Fehler:
1>main.obj : error LNK2005: "public: static void __cdecl Test::printStartText(void)" (?printStartText@Test@@SAXXZ) ist bereits in de.obj definiert.
1>main.obj : error LNK2005: "public: static float Test::projekt_Version" (?Projekt_Version@Test@@2MA) ist bereits in de.obj definiert.
main.cpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <iostream>
#include <string>
#include "de.cpp"
using namespace std;
int main()
{
string sInputConsole;
Test::printStartText();
while (sInputConsole != "end")
{
cin >> sInputConsole;
}
system("PAUSE");
return 0;
}
|
main.hpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
|
class Test
{
public:
static float Projekt_Version;
static void printStartText();
};
|
de.cpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#include <iostream>
#include "main.hpp"
using namespace std;
float Test::Projekt_Version = 1.0;
void Test::printStartText()
{
cout << "\t\t==============================" << endl;
cout << "\t\t\tVersion " << Projekt_Version << endl;
cout << "\t\t==============================" << endl << endl;
}
|
Wo liegt der Fehler?