"const" statement causes errors
-
Hi! I just try to implement class with members which return const values: class MyClass{ * * * protected: float GetVal() const {return val;} private: float val; } It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow some coding style. So your help is very essential for me. I code in VS 6.
-
Hi! I just try to implement class with members which return const values: class MyClass{ * * * protected: float GetVal() const {return val;} private: float val; } It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow some coding style. So your help is very essential for me. I code in VS 6.
-
Hi! I just try to implement class with members which return const values: class MyClass{ * * * protected: float GetVal() const {return val;} private: float val; } It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow some coding style. So your help is very essential for me. I code in VS 6.
-
Hi! I just try to implement class with members which return const values: class MyClass{ * * * protected: float GetVal() const {return val;} private: float val; } It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow some coding style. So your help is very essential for me. I code in VS 6.
What errors did you get? Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain) -
What errors did you get? Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)Thanks to all. I just fix it. The metter was not in "const" but in member name.
-
Hi! I just try to implement class with members which return const values: class MyClass{ * * * protected: float GetVal() const {return val;} private: float val; } It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow some coding style. So your help is very essential for me. I code in VS 6.
Like Mad___ said, you are returning a value - why would you want to return a const value? Isn't it the member, val, that is const? The method doesn't know the type of variable the return value is being stored in? Can anybody help please?!!? Cheers Angel =========================================================== The sooner you fall behind, the longer you have to catch up
-
Like Mad___ said, you are returning a value - why would you want to return a const value? Isn't it the member, val, that is const? The method doesn't know the type of variable the return value is being stored in? Can anybody help please?!!? Cheers Angel =========================================================== The sooner you fall behind, the longer you have to catch up
As I said I MUST code in certain style. So 'const' comes out of it.:):):)
-
Hi! I just try to implement class with members which return const values: class MyClass{ * * * protected: float GetVal() const {return val;} private: float val; } It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow some coding style. So your help is very essential for me. I code in VS 6.
You must add const in return type. Like this: const float GetVal()const {return val;} Because the type of val had been upgraded into "const float" in the GetVal function.