I did create an enum in order to choose between different options. In the last stage I get the choosen enum back.
But something is wrong with my switch case expression.
Enum:
public enum class MyObjForm { Rechteck, Ellipse };
Die Klasse:
public ref class Fenster2: public System::Windows::Form{
private: MyObjForm ^ form;
double breite;
double hoehe;
Fenster2(MyObjForm ^ obj, double h, double b) : form{ obj }, hoehe { h }, breite{ b }
{
InitializeComponent();
}
..
}
Switch Case:
switch (form) {
case MyObjForm::Rechteck:
gr->DrawRectangle(pen, 30.0f, 30.0f, breite, hoehe);
break;
case MyObjForm::Ellipse:
gr->DrawEllipse(pen, 30.0f, 30.0f, breite, hoehe);
break;
}
Visual Studio says there is a mistake in switch(form) it should be an integral type or an enumeration type.
But than it says: switch expression of the type "MyObjForm ^" isn't permitted.
And that the constant expressions aren't correct.
I do not see the correct answer, but I do not like to change from enum class to enum. Class is there to protect it, this way I think it should be there, even if it would be easier without. I use enum in order to learn how to use it.