I have a deprecated (Obsolete) function which returns an enum, and I have a new function which returns a List of enums.
One of the enum values is used only in the deprecated function, so is it possible to set an enum member as obsolete (because it can't be in the List)?
You can change default values of enum elements during declaration (if necessary).
The deprecated declaration lets you specify particular forms of function overloads as deprecated, whereas the pragma form applies to all overloaded forms of a function name. The deprecated declaration lets you specify a message that will display at compile time. The text of the message can be from a macro.
Deprecated attribute in C++14 with Examples Deprecated means the use of the name or entity declared with this attribute is allowed but discouraged for some reason.
Enum in java is a data type that contains fixed set of constants. When we required predefined set of values which represents some kind of data, we use ENUM. We always use Enums when a variable can only take one out of a small set of possible values.
Sure, you can:
public enum EE
{
A,
[Obsolete]
B
}
Actually, it is possible to generate either compiler warnings or compiler errors.
public enum TestEnum
{
A,
[Obsolete("Not in use anymore")]
B,
[Obsolete("Not in use anymore", true)]
C,
}
public class Class1
{
public void TestMethod()
{
TestEnum t1 = TestEnum.A; //Works just fine.
TestEnum t2 = TestEnum.B; //Will still compile, but generates a warning.
TestEnum t3 = TestEnum.C; //Will no longer compile.
}
}
This will work wherever you use an [Obsolete] attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With