#include <stdio.h>
struct TestStruct
{
int value;
TestStruct(int value, int prv)
: value(value),
_private(prv)
{
}
int GetPrivate() const
{
return _private;
}
private:
int _private;
int getPublic() const
{
return value;
}
};
int main()
{
TestStruct test(1, 3);
printf("public: %d\n", test.value);
printf("private: %d\n", test.GetPrivate());
printf("public: %d\n", test.getPublic()); //Compile error C2248: Cannot access private member declared in class 'TestStruct'.
printf("private: %d\n", test._private); //Compile error C2248: Cannot access private member declared in class 'TestStruct'.
return 0;
}