private template members

Dmitry Olshansky dmitry.olsh at gmail.com
Sun May 1 03:07:08 PDT 2011


On 01.05.2011 13:37, hunt0r wrote:
> hi,
>
> It seems that template members of a class are always public.
>
> having a class like:
> class Test
> {
>    private:
>      int x;
>      template test(T)
>      {
> 	void test(T t) {x= 100;}
>      }
>    public:
>      int getX() {return x;}
> }
>
> and calling:
> Test t = new Test;
> t.test();
>
> prints 100 instead of saying that the member test is not accessable.
> Is it not possible to get private template members with D?
It's not clear if you are calling it from separate module or from the 
same one. The access protection in D is module level, meaning you can 
access private members of the class in the same module.
There are some known bugs about it: 
http://d.puremagic.com/issues/show_bug.cgi?id=3108
<http://d.puremagic.com/issues/show_bug.cgi?id=314>

-- 
Dmitry Olshansky



More information about the Digitalmars-d-learn mailing list