Help with Syntax

Mar 10, 2018 at 3:24pm
On the reference page for Classes(II), here: http://www.cplusplus.com/doc/tutorial/templates/ , the code example at the bottom of the section "Const member functions" entitled "// overloading members on constness" shows some syntax I don't understand.

1
2
3
4
5
6
  MyClass foo (10);
  const MyClass bar (20);
  foo.get() = 15;         // ok: get() returns int&
// bar.get() = 25;        // not valid: get() returns const int&
  cout << foo.get() << '\n';
  cout << bar.get() << '\n';


Notice the function calls 'foo.get()' and 'bar.get()'. I've never seen assignment operations used with function calls before. They appear to be modifying the private data members of the objects, which shouldn't be possible because they're private.
Last edited on Mar 10, 2018 at 3:29pm
Mar 10, 2018 at 3:29pm
I always have problems with Syntax :(
You've been studying for a long time?
But I can play PoE with you and give you exalted orbs, for free ofc :-)
exalted has a golden color, is the size of a red apple.
It is an orb just like other poe orbs, but it is very often used to buy other currency, so it looks like in the Path of Exile https://odealo.com/games/path-of-exile
Buying and selling exalted orbs to improve your social position
Last edited on Mar 14, 2018 at 4:25pm
Topic archived. No new replies allowed.