Click here to Skip to main content
15,791,832 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: overzealous protection rules Pin
toxcct12-Jul-06 7:38
toxcct12-Jul-06 7:38 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 8:05
Zac Howland12-Jul-06 8:05 
QuestionRe: overzealous protection rules Pin
David Crow12-Jul-06 7:30
David Crow12-Jul-06 7:30 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 6:07
Dave Schumann12-Jul-06 6:07 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:09
Zac Howland12-Jul-06 7:09 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 7:15
Dave Schumann12-Jul-06 7:15 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:25
Zac Howland12-Jul-06 7:25 
GeneralRe: overzealous protection rules [modified] Pin
Dave Schumann12-Jul-06 7:48
Dave Schumann12-Jul-06 7:48 
well you can basically "completely circumvent" protection anyway. For example:

LIBRARY:

class A
{
protected:
int value;
};

MY CODE:

//now let's say I want to access value in an 'A' object I have. I just write this:

class A_breaker: public A
{
public:
int* accessValue()
{ return &value; }
};

void my_function (A& my_a)
{
int* value_ptr = ((A_breaker&)my_a).accessValue();
//now I can do anything
}

...so if they were trying to make "protected" bulletproof, they didn't succeed at all. (I've actually compiled the above and it's perfectly legal...and, incidentally, the cast to A_breaker is perfectly safe since A_breaker adds no data)

-- modified at 13:01 Wednesday 12th July, 2006
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 8:05
Zac Howland12-Jul-06 8:05 
AnswerRe: overzealous protection rules Pin
Zac Howland12-Jul-06 6:45
Zac Howland12-Jul-06 6:45 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 7:00
Dave Schumann12-Jul-06 7:00 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:21
Zac Howland12-Jul-06 7:21 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 7:50
Dave Schumann12-Jul-06 7:50 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 8:08
Zac Howland12-Jul-06 8:08 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 7:59
Dave Schumann12-Jul-06 7:59 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 8:14
Zac Howland12-Jul-06 8:14 
Answersolution Pin
Dave Schumann12-Jul-06 7:04
Dave Schumann12-Jul-06 7:04 
GeneralRe: solution Pin
Dave Schumann12-Jul-06 9:25
Dave Schumann12-Jul-06 9:25 
GeneralRe: solution Pin
BadKarma12-Jul-06 9:58
BadKarma12-Jul-06 9:58 
GeneralRe: solution Pin
led mike12-Jul-06 9:53
led mike12-Jul-06 9:53 
AnswerRe: overzealous protection rules Pin
Rilhas17-Jul-06 14:43
Rilhas17-Jul-06 14:43 
AnswerRe: overzealous protection rules Pin
David Crow31-Jul-06 11:28
David Crow31-Jul-06 11:28 
QuestionA (simple) Shell Question Pin
Dave Kerr12-Jul-06 5:49
Dave Kerr12-Jul-06 5:49 
QuestionLabeling Slider Bar stops Pin
LCI12-Jul-06 5:36
LCI12-Jul-06 5:36 
AnswerRe: Labeling Slider Bar stops Pin
pgrohs12-Jul-06 5:51
pgrohs12-Jul-06 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.