Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Calling a class' memver function from inside another class

Reply
Thread Tools

Calling a class' memver function from inside another class

 
 
philipwinder@googlemail.com
Guest
Posts: n/a
 
      08-03-2006
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

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-03-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Thomas J. Gritzan
Guest
Posts: n/a
 
      08-03-2006
(E-Mail Removed) schrieb:
> 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-lit...t.html#faq-5.8

--
Thomas
 
Reply With Quote
 
Phil Winder
Guest
Posts: n/a
 
      08-04-2006
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

 
Reply With Quote
 
Thomas Tutone
Guest
Posts: n/a
 
      08-04-2006
Phil Winder wrote:
> 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

 
Reply With Quote
 
Phil Winder
Guest
Posts: n/a
 
      08-06-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a variable inside a function of another class Yigit Turgut Python 5 01-10-2012 10:41 PM
Defining a function inside a function. Whats this feature ? How touse inside a class ? Sur Ruby 4 01-08-2008 02:50 PM
calling virtual function results in calling function of base class... Andreas Lagemann C++ 8 01-10-2005 11:03 PM
calling virtual function results in calling function of base class ... tiwy C++ 0 01-09-2005 11:17 PM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM



Advertisments