I just started C++ and I bought a few books. One of them, which I'm reading right now, has this code that I'm supposed to type in and learn how it works, but it has 4 errors when I compile:
I typed all of it in as it is in the book. What's wrong with it? This book is from 1994 so I'm hoping the code the author is using isn't outdated or something.Code:#include <iostream.h> class EnergyLevel { public: int Level; }; main() { EnergyLevel good; good.Level = 10; cout << "Good's energy level is at "; cout << good.Level << endl; good.Level ++; cout << "Good's energy level is now up to "; cout << good.Level << endl; }
Just in case you need to know, here are the errors:
(2) : error C2061: syntax error : identifier 'EnergyLevel'
(2) : error C2059: syntax error : ';'
(3) : error C2449: found '{' at file scope (missing function header?)
(6) : error C2059: syntax error : '}'