I am working on a college course and I am having difficulty with class constructors. I thought I understood them, but I can't get my code to compile cleanly. Here's the code for a problem similar to what I've been trying to do:
This example is the same as the one in my textbook, but I get a compiler error in Temperature.h:Code:// Temperature.h #ifndef TEMPERATURE #define TEMPERATURE #include <iostream> using namespace std; class Temperature { public: Temperature(); void print(ostream& out) const; private: double myDegrees; char myScale; } inline Temperature::Temperature() { myDegrees = 0.0; myScale = 'C'; } inline void Temperaure::print(ostream& out) { out << myDegrees << ' ' << myScale; } #endif // testTemp.cpp #include <cstdlib> #include <iostream> #include "Temperature.h" using namespace std; int main(int argc, char *argv[]) { Temperature temp1; temp1.print(cout); system("PAUSE"); return EXIT_SUCCESS; }
19 C:\Dev-Cpp\Temperature.h return type specification for constructor invalid
I didn't specify any return type, so why is it that I'm getting this error?
Thanks in advance,
Sean