Click here to Skip to main content
15,889,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:05
Zac Howland12-Jul-06 7:05 
QuestionRe: overzealous protection rules Pin
David Crow12-Jul-06 6:30
David Crow12-Jul-06 6:30 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 5:07
Dave Schumann12-Jul-06 5:07 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 6:09
Zac Howland12-Jul-06 6:09 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 6:15
Dave Schumann12-Jul-06 6:15 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 6:25
Zac Howland12-Jul-06 6:25 
GeneralRe: overzealous protection rules [modified] Pin
Dave Schumann12-Jul-06 6:48
Dave Schumann12-Jul-06 6:48 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:05
Zac Howland12-Jul-06 7:05 
AnswerRe: overzealous protection rules Pin
Zac Howland12-Jul-06 5:45
Zac Howland12-Jul-06 5:45 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 6:00
Dave Schumann12-Jul-06 6:00 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 6:21
Zac Howland12-Jul-06 6:21 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 6:50
Dave Schumann12-Jul-06 6:50 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:08
Zac Howland12-Jul-06 7:08 
GeneralRe: overzealous protection rules Pin
Dave Schumann12-Jul-06 6:59
Dave Schumann12-Jul-06 6:59 
GeneralRe: overzealous protection rules Pin
Zac Howland12-Jul-06 7:14
Zac Howland12-Jul-06 7:14 
Answersolution Pin
Dave Schumann12-Jul-06 6:04
Dave Schumann12-Jul-06 6:04 
GeneralRe: solution Pin
Dave Schumann12-Jul-06 8:25
Dave Schumann12-Jul-06 8:25 
Dave Schumann wrote:

Except when forming a pointer to member (expr.unary.op), the access must be through a pointer to, reference to, or object of the derived class itself (or any class derived from that class)


Here's a way to get around that rule (11.5.1), adapted from a guy named Olivier Langois:

struct A
{
A* partner;
void doodah()
{ ++partner->value; }
protected:
static int& access_value(A& a)
{return a.value;}

int value;
};
struct B: public A
{
void foobar()
{ access_value(*partner) += 2; }
};

I've added a PROTECTED static access_value() function in A. B can call it since it's a child. The ISO police go down in flames again. Huzzah!!!
GeneralRe: solution Pin
BadKarma12-Jul-06 8:58
BadKarma12-Jul-06 8:58 
GeneralRe: solution Pin
led mike12-Jul-06 8:53
led mike12-Jul-06 8:53 
AnswerRe: overzealous protection rules Pin
Rilhas17-Jul-06 13:43
Rilhas17-Jul-06 13:43 
AnswerRe: overzealous protection rules Pin
David Crow31-Jul-06 10:28
David Crow31-Jul-06 10:28 
QuestionA (simple) Shell Question Pin
Dave Kerr12-Jul-06 4:49
Dave Kerr12-Jul-06 4:49 
QuestionLabeling Slider Bar stops Pin
LCI12-Jul-06 4:36
LCI12-Jul-06 4:36 
AnswerRe: Labeling Slider Bar stops Pin
pgrohs12-Jul-06 4:51
pgrohs12-Jul-06 4:51 
GeneralRe: Labeling Slider Bar stops Pin
LCI12-Jul-06 5:51
LCI12-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.