473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calling a class' memver function from inside another class

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

Aug 3 '06 #1
5 1394
ph**********@googlemail.com 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
Aug 3 '06 #2
ph**********@googlemail.com 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
Aug 3 '06 #3
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

Aug 4 '06 #4
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

Aug 4 '06 #5
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

Aug 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: lallous | last post by:
Hello class A { public: virtual void Func1() = 0;
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
3
by: Roger Garrett | last post by:
I'm having a problem with a derived class. When a copy is made of the object it does indeed copy the additional member variables of the object but it does not seem to be copying the members of the...
12
by: Peter Cranz | last post by:
hello, I've got the following problem: I have a construct similar like this: namespace A { class X {
3
by: Zongjun Qi | last post by:
Hey, In the book <Effective C++>, the author provides an example to prove why we need "pass by reference". I redoed the example, and found something interesting. The codes are:...
5
by: Pyenos | last post by:
class WORK: def getwork(self): def choosetable(self):pass choosetable() #TypeError: choosetable() takes exactly 1 #argument (0 given) Calling choosetable() at the above location gives me the...
1
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.