The static_cast operator can explicitly convert an integral value to an enumeration type. If the value of the integral type does not fall within the range of enumeration values, the resulting enumeration value is undefined.

Can somebody explain the above stuff with example ??

Say you had:

enum priorities {zero,one,two,three};
priorities mypr;
int i = 4;
mypr = static_cast<priorities>(i);

What does mypr then mean? There's no value in the enum for 4, so should it be cast to 4? It's saying that this behavior could cause almost any results and should be avoided.

thanx buddy.......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.