"Daniel Lidström" <(E-Mail Removed)> wrote in
news:(E-Mail Removed)...
> Hello,
>
> why am I not allowed to put const keyword on memberfunctions as such:
>
> public __gc class C {
> public:
> int get() const;
> };
> ?
Because there are no "const" functions in the CLS.
Other .net languages like C# or VB.net don't have "const" types, so they
couldn't use classes exposing functions like these.
> Also, if I return a pointer to as String, do I have to add const to make
it
> non-changeable? For example:
>
> public __gc class C {
> public:
> System::String* get() { return s; }
>
> System::String* s;
> };
>
> What happens if I do:
> C* c;
> c->s = "string";
> c->get() = "vector"; // can't compile it
System::String's are always unchangable.
If you modify a string, a new String instance will be created with the old
instance unchanged.
>
> Sorry if these are simple questions...
I'd suggest learning the .net framework with a language like C# or VB.net
instead of MC++.
Niki
|