Calling a class' memver function from inside another class

P

philipwinder

Hi, im a bit stuck with a little problem. I have created two classes,
CDrawControl and CSoundControl, and I have first created a CDrawControl
object and then a CSoundControl. The problem is that I am trying to
call a function within CDrawControl from within CSoundControl but it
causes errors. How can I get around this?

Just to reitoriate:

CDrawControl oMyDrawControl;
CSoundControl oMySoundControl;
.......

// From within oMySoundControl class
...
oMyDrawControl:Somefunction();
...

Many thanks,

Phil Winder
 
V

Victor Bazarov

Hi, im a bit stuck with a little problem. I have created two classes,
CDrawControl and CSoundControl, and I have first created a
CDrawControl object and then a CSoundControl. The problem is that I
am trying to call a function within CDrawControl from within
CSoundControl but it causes errors.

What errors? I don't see no errors...
How can I get around this?

Around what?
Just to reitoriate:

CDrawControl oMyDrawControl;
CSoundControl oMySoundControl;
.......

// From within oMySoundControl class
...
oMyDrawControl:Somefunction();

That's not the right syntax. Do you mean

oMyDrawContro.Somefunction();

?


V
 
T

Thomas J. Gritzan

Hi, im a bit stuck with a little problem. I have created two classes,
CDrawControl and CSoundControl, and I have first created a CDrawControl
object and then a CSoundControl. The problem is that I am trying to
call a function within CDrawControl from within CSoundControl but it
causes errors. How can I get around this?

Just to reitoriate:

CDrawControl oMyDrawControl;
CSoundControl oMySoundControl;
.......

// From within oMySoundControl class
...
oMyDrawControl:Somefunction();
...

As you don't want to show us your real code along with the class
definitions, not even you error messages, I have to guess:

1) You have a ":" where you should have a "."

Try: oMyDrawControl.Somefunction();

2) You try to call a member function that is not public.

However, you should study the FAQ, that would help a lot:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
 
P

Phil Winder

Sorry, yes you are right I did mean:

oMyDrawControl.Somefunction();

Just a typo, the error it just the same. Also, I didnt think it
requires full code because I thought was just inexperience, hence the
following snippit.

CDrawControl oMyDrawControl;
CSoundControl oMySoundControl;
.......

// From within oMySoundControl class
...
oMyDrawControl.Somefunction();
...

error C2065: 'oMyDrawControl' : undeclared identifier
error C2228: left of '.DrawSpectrum' must have class/struct/union
 
T

Thomas Tutone

Phil said:
Sorry, yes you are right I did mean:

oMyDrawControl.Somefunction();

Just a typo, the error it just the same. Also, I didnt think it
requires full code because I thought was just inexperience, hence the
following snippit.

CDrawControl oMyDrawControl;
CSoundControl oMySoundControl;
.......

// From within oMySoundControl class
...
oMyDrawControl.Somefunction();
...

error C2065: 'oMyDrawControl' : undeclared identifier
error C2228: left of '.DrawSpectrum' must have class/struct/union

Please post a short piece of compilable code that will allow us to
duplicate the problem. Until you do that, we can't help you. Please
look at the FAQ you were referred to before.

Good luck.

Best regards,

Tom
 
P

Phil Winder

I was going to write a rant, but i decided to delete it and just say
that can people please write in a mannor in which they would talk to
others, since patronising is actually quite offensive.

All I wanted to know was, was that syntax correct, the ideas behind it
right and it should have been a quick 5 second answer.

Ive decided to go another way and figured out another way.

Thanks anyway,

Phil Winder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top