Private field - why does this compile?

Hi
in root v 4.00 on Fermi RedHat I try to compile this:
tst2.cc:

#include
class datum{
private:
int dat;
void show(){
std::cerr<<"?!?!?!\n\n";
}
public:
datum(){dat=3;}
};

void tst2(){
datum dt;
std::cerr<<dt.dat<<"\n";
dt.show();
}

In my root session:
root [0] .L tst2.cc++
Info in : creating shared library /cdf/data3a/fedorko/selection_04261030/./tst2_cc.so
root [1] tst2()
3
?!?!?!

Why can I access private variables and functions?
Is this fixed later?
thanks,
Wojtek

Hi,

[quote=“fedorko”]Why can I access private variables and functions?[/quote]Because Cint doesn’t stop you from soing so.

[quote=“fedorko”]Is this fixed later?[/quote]It’s on the to-do list. For now you’ll have to compile your code (.L mycode.C+) if you want to ensure that private vars are not accessible.
Axel.

I do compile my code… (.L mycode.C+)
maybe I am posting to the wrong list but I thaught that the built-in compiler was akin to cint…
Wojtek

Hi,

When we build dictionary (and technically this is what happens when you use ACLiC (mycode.C+)), to properly access the information, we ‘break’ the privacy (#define private public). We are moving away from this implementation and thus this should be fixed in a future release.

Cheers,
Philippe.

This is fixed in the CVS repository as of 2007/01/26

Cheers,
Philippe