Hab ein Problem bei nem selbstgeschriebenen C++ Code
Hier der Code:
header.hpp
Hoffentlich könnt ihr mir helfen..komme nicht mehr weiter
PS:Fange gerade an C++ zu lernen. :baby:
Hier der Code:
Code:
#include "Header.hpp"
int main()
{
pocalc taschenrechner;
calc rechnung;
std::cout << "Welcome to the Int-Calc v1.0" << std::endl;
std::cout << "\n********************************************************************\n";
std::cout << "\nPlease type two numbers you want to calculate with.\n";
std::cout << "\nNumber 1: ";
taschenrechner.Seta();
std::cout << "\nNumber 2: ";
taschenrechner.Setb();
rechnung.Setab(taschenrechner.GetVariablea(), taschenrechner.GetVariableb());
std::cout << "\n********************************************************************\n";
std::cout << "\n\nWhich operation of calculating do you want to use?" << std::endl;
std::cout << "\n1 Addition\n";
std::cout << "2 Subtraction\n";
std::cout << "3 Multiplication\n";
std::cout << "4 Division\n" << std::endl;
std::cout << "Mode of Operation: ";
std::cin >> rechnung.moo;
if (rechnung.moo == 1)
return rechnung.addition(int a, int b);
else
{
if (rechnung.moo == 2)
return rechnung.subtraction(int a, int b);
else
{
if (rechnung.moo == 3)
return rechnung.multiplication(int a, int b);
else
{
if (rechnung.moo == 4)
return rechnung.division(int a, int b);
}
}
}
return 0;
}
Code:
#include <iostream>
class pocalc
{
public:
void Seta() {std::cin >> a;}
void Setb() {std::cin >> b;}
int GetVariablea() const {return a;}
int GetVariableb() const {return b;}
private:
int a, b;
};
class calc
{
public:
void Setab (int ab, int ba) {a = ab; b = ba;}
int GetResult () const {return Result;}
int addition (int a, int b) {Result = a + b;}
int subtraction (int a, int b) {Result = a - b;}
int multiplication (int a, int b) {Result = a * b;}
int division (int a, int b) {Result = a / b;}
int moo; //mode of operation
private:
int a, b, Result;
};
Hoffentlich könnt ihr mir helfen..komme nicht mehr weiter
PS:Fange gerade an C++ zu lernen. :baby: