Hello,

Just to not cause any contreversy:
"I understand that class definitions go in headers and method
implementations go in CPP files, however to simplify things, I put everything
under one listing!"

okay!

"A_CTR" class derives from "actions" class and "actions" class derives from
"components" class.

ALSO:

"T_CTR" class derives from "transitions" class and "transitions class
derives from "components" class.

So, its doing like a pyramid, with "components" class at the top, and where
"actions" and "transitions" classes are right below "coponents". Further,
"A_CTR" class is underneath "actions" and "T_CTR" is under "transitions".

I guess this can be better viwed in the code below.

Please consider the following code and see question after code:
===============================================

class components
{
public:
components(){}
components(int Flag);
virtual ~components() {}
static int FLAG_AllTrueInCase;

protected:
};

//ADT
class actions:public components
{
public:
actions(){}
virtual ~actions(){}
virtual bool conv_BOOL_INPUT_INTERNAL(
int Bool_ID_INPUT1,int Bool_ID_INTERNAL1, IO *io);
protected:
};

class A_CTR:public actions
{
public:
A_CTR(){}
virtual ~A_CTR(){}
virtual int SYS_getCnstCount(int i_COunterID)const;
virtual void setCounter(int i_CounterID,int i_CountCnst);

protected:
int iCount1Cnst;
int iCount2Cnst;
int iCount3Cnst;
};

int A_CTR::SYS_getCnstCount(int iCounterID)const
{
...other code...

return iCount1Cnst;
}

void A_CTR::setCounter(int iCounterID, int iCountCnst)
{
...other code...

iCount1Cnst = iCountCnst;
}


//ADT
class transitions:public components
{
public:
transitions(){}
virtual ~transitions(){}
};

class T_CTR:public transitions
{
public:
T_CTR(){}
virtual ~T_CTR(){}
virtual bool get_CTR_Ellapsed(int i_CounterID, int i_BranchDest);
protected:
int iC1CurrentCount;
int iC2CurrentCount;
int iC3CurrentCount;
};

bool T_CTR::get_CTR_Ellapsed(int iCounterID,int iBranchDest)
{
int xxx;

xxx = A_CTR::SYS_getCnstCount(1); /// *** ERROR! *** on this line!
}
===================================================

What if we are in a method of the T_CTR class and we wish to access a member
of the A_CTR class?

The following line:

xxx = A_CTR::SYS_getCnstCount(1); /// *** ERROR! *** on this line!

causes the following error:

c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\WndProc_ClassMethods.h(375):
error C2352: 'A_CTR::SYS_getCnstCount' : illegal call of non-static member
function

I somehow have the feeling I have coded something wrong *again*..... I am
looking hard to find the problem, but obviously not hard enough, and
furthermore, a book example does the same thing... I don't know what to make
of it?

Just when I thought that I was getting this classes stuff, I get this! :-)

Can someone please tell me what am I doing wrong?

*ALL* support appreciated!


--
Best regards
Robert

RE: OOP problem! by Robby

Robby
Mon Jun 05 15:56:02 CDT 2006

oops!

Sorry for the misleading title of my post, I don't think this is an object
oriented problem, but more of a class member accessing one.

--
Best regards
Robert


"Robby" wrote:

> Hello,
>
> Just to not cause any contreversy:
> "I understand that class definitions go in headers and method
> implementations go in CPP files, however to simplify things, I put everything
> under one listing!"
>
> okay!
>
> "A_CTR" class derives from "actions" class and "actions" class derives from
> "components" class.
>
> ALSO:
>
> "T_CTR" class derives from "transitions" class and "transitions class
> derives from "components" class.
>
> So, its doing like a pyramid, with "components" class at the top, and where
> "actions" and "transitions" classes are right below "coponents". Further,
> "A_CTR" class is underneath "actions" and "T_CTR" is under "transitions".
>
> I guess this can be better viwed in the code below.
>
> Please consider the following code and see question after code:
> ===============================================
>
> class components
> {
> public:
> components(){}
> components(int Flag);
> virtual ~components() {}
> static int FLAG_AllTrueInCase;
>
> protected:
> };
>
> //ADT
> class actions:public components
> {
> public:
> actions(){}
> virtual ~actions(){}
> virtual bool conv_BOOL_INPUT_INTERNAL(
> int Bool_ID_INPUT1,int Bool_ID_INTERNAL1, IO *io);
> protected:
> };
>
> class A_CTR:public actions
> {
> public:
> A_CTR(){}
> virtual ~A_CTR(){}
> virtual int SYS_getCnstCount(int i_COunterID)const;
> virtual void setCounter(int i_CounterID,int i_CountCnst);
>
> protected:
> int iCount1Cnst;
> int iCount2Cnst;
> int iCount3Cnst;
> };
>
> int A_CTR::SYS_getCnstCount(int iCounterID)const
> {
> ...other code...
>
> return iCount1Cnst;
> }
>
> void A_CTR::setCounter(int iCounterID, int iCountCnst)
> {
> ...other code...
>
> iCount1Cnst = iCountCnst;
> }
>
>
> //ADT
> class transitions:public components
> {
> public:
> transitions(){}
> virtual ~transitions(){}
> };
>
> class T_CTR:public transitions
> {
> public:
> T_CTR(){}
> virtual ~T_CTR(){}
> virtual bool get_CTR_Ellapsed(int i_CounterID, int i_BranchDest);
> protected:
> int iC1CurrentCount;
> int iC2CurrentCount;
> int iC3CurrentCount;
> };
>
> bool T_CTR::get_CTR_Ellapsed(int iCounterID,int iBranchDest)
> {
> int xxx;
>
> xxx = A_CTR::SYS_getCnstCount(1); /// *** ERROR! *** on this line!
> }
> ===================================================
>
> What if we are in a method of the T_CTR class and we wish to access a member
> of the A_CTR class?
>
> The following line:
>
> xxx = A_CTR::SYS_getCnstCount(1); /// *** ERROR! *** on this line!
>
> causes the following error:
>
> c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\WndProc_ClassMethods.h(375):
> error C2352: 'A_CTR::SYS_getCnstCount' : illegal call of non-static member
> function
>
> I somehow have the feeling I have coded something wrong *again*..... I am
> looking hard to find the problem, but obviously not hard enough, and
> furthermore, a book example does the same thing... I don't know what to make
> of it?
>
> Just when I thought that I was getting this classes stuff, I get this! :-)
>
> Can someone please tell me what am I doing wrong?
>
> *ALL* support appreciated!
>
>
> --
> Best regards
> Robert

Re: OOP problem! by David

David
Mon Jun 05 17:10:26 CDT 2006

Robby wrote:

> oops!
>
> Sorry for the misleading title of my post, I don't think this is an object
> oriented problem, but more of a class member accessing one.
>

Robby:

'A_CTR::SYS_getCnstCount' : illegal call of non-static member function

The error says exactly what the problem is. A non-static member function
requires an object; you don't have one. A_CTR is not a base class of T_CTR.

David Wilkinson

======================

Re: OOP problem! by Robby

Robby
Mon Jun 05 17:25:02 CDT 2006

Hi David,

Oh boy! This will change the I am doing things....

Okay then! Thanks for your post!

and have a nice day!

--
Best regards
Robert


"David Wilkinson" wrote:

> Robby wrote:
>
> > oops!
> >
> > Sorry for the misleading title of my post, I don't think this is an object
> > oriented problem, but more of a class member accessing one.
> >
>
> Robby:
>
> 'A_CTR::SYS_getCnstCount' : illegal call of non-static member function
>
> The error says exactly what the problem is. A non-static member function
> requires an object; you don't have one. A_CTR is not a base class of T_CTR.
>
> David Wilkinson
>
> ======================
>