Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How its accessing the private members? (http://www.go4expert.com/forums/accessing-private-t398/)

coderzone 27Jul2005 12:23

How its accessing the private members?
 
This does not work as normal
Code:

class test
{
private:
        class privateStruct
        {
        public:
                int m;
                privateStruct(int p){m=p;}
        };
};

void ff()
{
        test::privateStruct ps(4);
        throw ps; //Does not work..
}

void main()
{
        try
        {
                ff();
        }
        catch(...)
        {
        }
}

but the code below works
Code:

class test
{
private:
        class privateStruct
        {
        public:
                int m;
                privateStruct(int p){m=p;}
        };
};

void ff()
{
        throw test::privateStruct(4); //Work why
}

void main()
{
        try
        {
                ff();
        }
        catch(...)
        {
        }
}

How??

shabbir 27Jul2005 21:17

Re: How its accessing the private members?
 
Probably a bug in VC compiler. Its creates a Nameless temporary object at

throw test::privateStruct(4);

Or similar statements like

return test::privateStruct(4);

and probably VC is not tested for such conditions well enough.


All times are GMT +5.5. The time now is 01:38.