Okay, I am learning C++ using the tutorial on this site and also reading learning c++ in 21 days.
I am up to the part of variables and constants. It says that a variable can be defined and initialised from the beginning like this:
Ulong myAge = 23;
But the book also described it as a constant. Can someone please explain the difference. I am not getting this very well.
Also, about enumerated constants, I am having problems understanding this. Can someone explain this to me as well? I tried to do some code like this:
#include <iostream.h>
typedef unsigned short int Uint;
void main()
{
enum Jerky{Uint j=1, Uint o=2, Uint e=3};
int x;
Jerky joey;
joey=Jerky(3);
cout <<joey;
return 0;
}
I am using Visual C++ 6.0 introductory edition. It gives me the following errors:
C:\JOEY\Program Files\Microsoft Visual Studio\VC98\tests\enumsvare.cpp(7) : error C2061: syntax error : identifier 'j'
C:\JOEY\Program Files\Microsoft Visual Studio\VC98\tests\enumsvare.cpp(10) : error C2146: syntax error : missing ';' before identifier 'joey'
C:\JOEY\Program Files\Microsoft Visual Studio\VC98\tests\enumsvare.cpp(10) : error C2501: 'Jerky' : missing storage-class or type specifiers
C:\JOEY\Program Files\Microsoft Visual Studio\VC98\tests\enumsvare.cpp(10) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
enumsvare.obj - 4 error(s), 0 warning(s)
can someone tell me what I did wrong here?
Thank you for your time in advance.
Joey