D
D
DmitryProsh2016-08-31 23:44:50
Programming
DmitryProsh, 2016-08-31 23:44:50

What difference does it make where the const is?

What is the difference between the 2nd entries below?
In the first, the return value becomes constant, and in the second?
1) const float MyClass::operator float()
2) float MyClass::operator float() const

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2016-08-31
@DmitryProsh

The second tells the compiler that the call does not change the state of the object. Such methods can be called on const MyClass&.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question