Hallo,
komme leider nicht weiter. Problem ist mit Inkluden von Dateien
Fehlermeldung:
Anbei die Dateien:
main.cpp:
main.h:
calc.cpp:
calc.h:
gui.cpp:
gui.h:
Ich danke euch im voraus
komme leider nicht weiter. Problem ist mit Inkluden von Dateien
Fehlermeldung:
PHP:
1>gui.obj : error LNK2005: "int ziffer1" (?ziffer1@@3HA) ist bereits in calc.obj definiert.
1>gui.obj : error LNK2005: "int a" (?a@@3HA) ist bereits in calc.obj definiert.
main.cpp:
PHP:
#pragma once
#include "main.h"
int main()
{
gui::einlesen();
calc::calculate(a,b,c,d,operand);
gui::printout(ziffer1,ziffer2,overflow_char);
}
main.h:
PHP:
#pragma once
#include <iostream>
#include <string>
#include "calc.h"
#include "gui.h"
using namespace std;
int a,b,c,d;
char operand;
calc.cpp:
PHP:
#include "main.h"
namespace calc
{
void calculate(int a, int b, int c, int d, char operand)
{
if(operand=='+')
{
ziffer2=b+d;
if(ziffer2>10)
{
a++;
ziffer2=ziffer2%10;
}
ziffer1=a+c;
if(ziffer1>10)
overflow_char='x';
}
else
{
if(b<d)
{
b+=10;
c++;
}
ziffer2=b-d;
ziffer1=a-c;
}
}
}
calc.h:
PHP:
#pragma once
char overflow_char='\0';
int ziffer1,ziffer2;
namespace calc
{
void calculate(int a, int b, int c, int d, char operand);
}
gui.cpp:
PHP:
#include "main.h"
namespace gui
{
void einlesen(void)
{
cout<<"Bitte geben Sie die vier Ziffern ein: ";
cin>>a>>b>>c>>d;
cout<<"Bitte geben Sie '+' oder '-' ein: ";
cin>>operand;
}
inline void printout(int a,int b, char overflow_char)
{
if(overflow_char=='x')
{
cout<<"OVERFLOW";
}
else
{
cout<<"Ergebnis: "<<ziffer1<<ziffer2<<endl;
}
}
}
gui.h:
PHP:
#pragma once
#include "main.h"
namespace gui
{
void einlesen(void);
inline void printout(int a,int b, char overflow_char);
}
Ich danke euch im voraus