#Why Would CpP needs 2 accessor, `::` and `.` ?

17 messages · Page 1 of 1 (latest)

vocal sparrow
#

Is it a compromise to a historical need, or does it really need to make this distinction?

fossil oliveBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

fossil oliveBOT
# fossil olive

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

ocean flame
#

:: is for static, . is for non-static

#

:: is also used to refer to things outside of expressions (and therefore statically)

#

Ie you can get the address of a member function by doing &Foo::func

#

As for why it was separated like this, I am not sure... I imagine that early in C++'s design, Bjarne wanted to clearly separate what was a C-style access of a member vs the new feature he introduced (static scoping)

lapis fulcrum
honest kelpBOT
#
Program Output
1
2
lapis fulcrum
vocal sparrow
fossil oliveBOT
#

@vocal sparrow Has your question been resolved? If so, type !solved :)

vocal sparrow
#

!solved

fossil oliveBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

gloomy crystal
#

More likely it's what DXPower said. And this case just happened to benefit from it

lapis fulcrum