I am trying to access a .NET structure member but compilation fails even for this simple example:
.h:
using namespace System::Drawing;
namespace MyNamespace{
public ref class MyClass{
public:
MyClass();
static const System::Drawing::Size MinimumSize = System::Drawing::Size(20,20);
}
}
.cpp:
#include "MyInclude.h"
MyClass::MyClass(){
int i = MinimumSize.Width;
// .....
}
The statement which assigns the MinimumSize.Width to the local variable i fails to compile:
- "No instance of function "System::Drawing::Size::Width::get()" matches the argument list and object (the object has type qualifiers that prevent a match) object type is const System::Drawing::Size
The assignment compiles without error when I remove the "const" in the declaration but I want to keep the value public and read-only.
Can somebody give me a hint how to specify that?