Today I have tried to make a class named calculator, for a physics project and as the name suggests, my class would just do calculations. Being a program for physics, it's expected to need calculus formulas; and they would be calculated using parameterized functions, returning a string consisting of a double and the measuring unit like this: 177 J/Kg*K
Now, let's get to the problem:
So i have tested my functions, and after that I decided to make it into Object Oriented Programming as it would make things a little bit simpler for me, at least... After making the class, I got an error saying that
"string" in "class Calculator" doesn't define a type
Here is the code:
Calculator.h
#ifndef CALCULATOR_H
#define CALCULATOR_H
#include <iostream>
using namespace std;
class Calculator{
private:
public:
Calculator();
string capCalorica(double cReceived, double varTemp);
string caldSpecifica(double cReceived, double varTemp, double mass);
};
#endif // CALCULATOR_H
Calculator.cpp
#include "Calculator.h"
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
Calculator::Calculator(){
cout<<"Calculus Module Initialized!"<<endl;
Sleep(2000);
system("cls");
}
Calculator::string capCalorica(double cReceived, double varTemp)){
stringstream sstr;
double result = cReceived/varTemp;
sstr<<result<<" J/Kg";
return sstr.str();
}
Calculator::string caldSpecific(double cReceived, double mass, double varTemp){
stringstream sstm;
double result = cReceived/(mass*varTemp);
sstm<<result<<" J/Kg*K";
return sstm.str();
}
The error is in the cpp file, wherever i defined a string returning function