What is the difference between scope and encapsulation? (C++) -


picking programming after 8 years of... not programming (starting college soon, brushing on old knowledge).

what difference between scope , encapsulation? seem rather similar.

a scope area within program within automatic variables may created , @ end of automatically destroyed. examples function body or code-block of for-loop.

scopes may enclose 1 , variables in outer scope may, or may not, accessible code in inner scope.

for example global scope encloses other scopes , variables created in global scope visible other scopes (according various name resolution rules).

therefore scope refers visibility of objects can accessed given point in program.

there different types of scope each own visibility rules, example class scope refers visibility of member variables , member functions member functions of class object.

for more detailed definitions see http://en.cppreference.com/w/cpp/language/scope

encapsulation when hide specific data makes object , focus on how object behaves according function interface. in c++ data hiding achieved marking data private or protected rendering inaccessible outside structure within defined.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -