Access Private member ouside the class???
why dot net calls pointers unsafe ???
Try this c++ ,com code: The class has a private variable and has no assignment statement as past of it. But still the code manages to assign a value to the private member:
#include "comdef.h"
class ClassNameHolder
{
private:
BSTR bstrVal;
public:
BSTR* ReturnMe() {return &bstrVal;}
BSTR GiveMeOut() {return bstrVal;}
};
void AssignName(BSTR *val);
void main()
{
CoInitialize(0);
ClassNameHolder *obj = new ClassNameHolder();
AssignName(obj->ReturnMe());
_bstr_t bstrbb = obj->GiveMeOut();
CoUninitialize();
}
void AssignName(BSTR *val)
{
*val = ::SysAllocString(L"Arun");
}
Try this c++ ,com code: The class has a private variable and has no assignment statement as past of it. But still the code manages to assign a value to the private member:
#include
class ClassNameHolder
{
private:
BSTR bstrVal;
public:
BSTR* ReturnMe() {return &bstrVal;}
BSTR GiveMeOut() {return bstrVal;}
};
void AssignName(BSTR *val);
void main()
{
CoInitialize(0);
ClassNameHolder *obj = new ClassNameHolder();
AssignName(obj->ReturnMe());
_bstr_t bstrbb = obj->GiveMeOut();
CoUninitialize();
}
void AssignName(BSTR *val)
{
*val = ::SysAllocString(L"Arun");
}

