M
Morten Aune Lyrstad
I am in the process of writing a virtual machine. I know that one should
not give access to private variables in a class (by using friend) but
wouldn't that speed up execution? Like this:
class Script;
class Instruction
{
...
private
int someCode;
friend Script;
}
class Script
{
...
void Execute(...)
{
switch (currentScript.someCode) {
... ... ...
rather than using a function by the name GetCode or whatever? Or is
there some other reason why this should not be done? As long as the user
of these scripts don't get access to those variables, everything should
be ok, right?
Yours,
Morten Aune Lyrstad
not give access to private variables in a class (by using friend) but
wouldn't that speed up execution? Like this:
class Script;
class Instruction
{
...
private
int someCode;
friend Script;
}
class Script
{
...
void Execute(...)
{
switch (currentScript.someCode) {
... ... ...
rather than using a function by the name GetCode or whatever? Or is
there some other reason why this should not be done? As long as the user
of these scripts don't get access to those variables, everything should
be ok, right?
Yours,
Morten Aune Lyrstad