How to resolve the algorithm Break OO privacy step by step in the FreeBASIC programming language
How to resolve the algorithm Break OO privacy step by step in the FreeBASIC programming language
Table of Contents
Problem Statement
Show how to access private or protected members of a class in an object-oriented language from outside an instance of the class, without calling non-private or non-protected members of the class as a proxy.
The intent is to show how a debugger, serializer, or other meta-programming tool might access information that is barred by normal access methods to the object but can nevertheless be accessed from within the language by some provided escape hatch or reflection mechanism.
The intent is specifically not to demonstrate heroic measures such as peeking and poking raw memory.
Note that cheating on your type system is almost universally regarded
as unidiomatic at best, and poor programming practice at worst.
Nonetheless, if your language intentionally maintains a double-standard for OO privacy, here's where you can show it off.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Break OO privacy step by step in the FreeBASIC programming language
Source code in the freebasic programming language
'FB 1.05.0 Win64
#Undef Private
#Undef Protected
#Define Private Public
#Define Protected Public
Type MyType
Public :
x As Integer = 1
Protected :
y As Integer = 2
Private :
z As Integer = 3
End Type
Dim mt As MyType
Print mt.x, mt.y, mt.z
Print
Print "Press any key to quit"
Sleep
You may also check:How to resolve the algorithm Rock-paper-scissors step by step in the Ring programming language
You may also check:How to resolve the algorithm Loops/For step by step in the ARM Assembly programming language
You may also check:How to resolve the algorithm Loops/Downward for step by step in the Julia programming language
You may also check:How to resolve the algorithm ABC problem step by step in the Fortran programming language
You may also check:How to resolve the algorithm Comma quibbling step by step in the Fortran programming language