COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

• Email
• Follow

In the following source code,
class CA
{
CB b1;

void funca()
{
b1.funcb();
};
.......
};

void main
{
CB bArray[6];
....
}

I am hoping that, in class CA, b1 is exactly same as bArray[1] in the main
program. That means, for funca in CA, b1.funcb() is same as
bArray[1].funcb().

The only approach i can think about is defining bArray as a global variable.
Any other techniques? Thank you very much.

--
***********MERRY CHRISMAS***************
Thanks and Best Regards

Yan ZHANG
http://www.nict.com.sg/zhang/


 0
Reply buaanupt (78) 12/27/2004 11:04:35 AM

See related articles to this posting

bArray in your code is a definition, while CA is a declaration of a class.
I guess you want to get a instance of CA, which has the member b1 identical
with bArray[1]. Simply, you can define a constructor for CA to initiate its
member b1. Whenever you want a object of CA, you just pass bArray[1] to the
constructor.
bArray does not have to be a global variable.

"Yan ZHANG" <buaanupt@sina.com> wrote in message news:33a98oF3uajuoU1@individual.net...
> In the following source code,
> class CA
> {
>     CB b1;
>
>     void funca()
>     {
>      b1.funcb();
>     };
> ......
> };
>
> void main
> {
>     CB bArray[6];
> ...
> }
>
> I am hoping that, in class CA, b1 is exactly same as bArray[1] in the main
> program. That means, for funca in CA, b1.funcb() is same as
> bArray[1].funcb().
>
> The only approach i can think about is defining bArray as a global variable.
> Any other techniques? Thank you very much.
>
> --
> ***********MERRY CHRISMAS***************
> Thanks and Best Regards
>
> Yan ZHANG
> http://www.nict.com.sg/zhang/
>
>


 0
Reply molewy (9) 12/27/2004 11:20:10 AM

Thank you very much for your comments. do you mind give some sample source
code for this? Thanks a lot!

"Mole Wang" <molewy@yahoo.com.cn> wrote in message
news:cqos0s$aji$1@mail.cn99.com...
> bArray in your code is a definition, while CA is a declaration of a class.
> I guess you want to get a instance of CA, which has the member b1
identical
> with bArray[1]. Simply, you can define a constructor for CA to initiate
its
> member b1. Whenever you want a object of CA, you just pass bArray[1] to
the
> constructor.
> bArray does not have to be a global variable.
>
>
> "Yan ZHANG" <buaanupt@sina.com> wrote in message
news:33a98oF3uajuoU1@individual.net...
> > In the following source code,
> > class CA
> > {
> >     CB b1;
> >
> >     void funca()
> >     {
> >      b1.funcb();
> >     };
> > ......
> > };
> >
> > void main
> > {
> >     CB bArray[6];
> > ...
> > }
> >
> > I am hoping that, in class CA, b1 is exactly same as bArray[1] in the
main
> > program. That means, for funca in CA, b1.funcb() is same as
> > bArray[1].funcb().
> >
> > The only approach i can think about is defining bArray as a global
variable.
> > Any other techniques? Thank you very much.
> >
> > --
> > ***********MERRY CHRISMAS***************
> > Thanks and Best Regards
> >
> > Yan ZHANG
> > http://www.nict.com.sg/zhang/
> >
> >
>
>


 0
Reply buaanupt (78) 12/27/2004 11:29:38 AM

class CA {
CB b1;
public:
CA(const CB &b) : b1(b) {}
void funca() {
b1.funcb();
}
};
void main()
{
CB bArray[6];
..................
CA ca(bArray[1]);
}
CB must have a well-defined copy constructor.

"Yan ZHANG" <buaanupt@sina.com> wrote in message news:33aanoF3tc0isU1@individual.net...
> Thank you very much for your comments. do you mind give some sample source
> code for this? Thanks a lot!
>
>
> "Mole Wang" <molewy@yahoo.com.cn> wrote in message
> news:cqos0s$aji$1@mail.cn99.com...
> > bArray in your code is a definition, while CA is a declaration of a class.
> > So, what's your meaning?
> > I guess you want to get a instance of CA, which has the member b1
> identical
> > with bArray[1]. Simply, you can define a constructor for CA to initiate
> its
> > member b1. Whenever you want a object of CA, you just pass bArray[1] to
> the
> > constructor.
> > bArray does not have to be a global variable.
> >
> >
> > "Yan ZHANG" <buaanupt@sina.com> wrote in message
> news:33a98oF3uajuoU1@individual.net...
> > > In the following source code,
> > > class CA
> > > {
> > >     CB b1;
> > >
> > >     void funca()
> > >     {
> > >      b1.funcb();
> > >     };
> > > ......
> > > };
> > >
> > > void main
> > > {
> > >     CB bArray[6];
> > > ...
> > > }
> > >
> > > I am hoping that, in class CA, b1 is exactly same as bArray[1] in the
> main
> > > program. That means, for funca in CA, b1.funcb() is same as
> > > bArray[1].funcb().
> > >
> > > The only approach i can think about is defining bArray as a global
> variable.
> > > Any other techniques? Thank you very much.
> > >
> > > --
> > > ***********MERRY CHRISMAS***************
> > > Thanks and Best Regards
> > >
> > > Yan ZHANG
> > > http://www.nict.com.sg/zhang/
> > >
> > >
> >
> >
>
>


 0
Reply molewy (9) 12/27/2004 12:08:10 PM

"Yan ZHANG" <buaanupt@sina.com> a �crit dans le message de news:
33a98oF3uajuoU1@individual.net...
> In the following source code,
> class CA
> {
>    CB b1;
>
>    void funca()
>    {
>     b1.funcb();
>    };
> ......
> };
>
> void main

main() returns an int.

int main()

> {
>    CB bArray[6];
> ...
> }
>
> I am hoping that, in class CA, b1 is exactly same as bArray[1] in the main
> program. That means, for funca in CA, b1.funcb() is same as
> bArray[1].funcb().

Be careful with the words you use.  Differentiate between object and class.

> The only approach i can think about is defining bArray as a global
> variable.
> Any other techniques? Thank you very much.

You need CA to have a reference to an object.

class CA
{
private:
CB &cb_;

public:
CA(CB &cb)
: cb_(cb)
{
}

void f()
{
cb_.g();
}
};

int main()
{
CB cbs[6];

CA ca(cbs[1]);
ca.f();        // calls cbs[1].g()
}

Jonathan


 0
Reply jonathanmcdougall2 (279) 12/27/2004 12:55:34 PM

"Mole Wang" <molewy@yahoo.com.cn> a �crit dans le message de news:
cqour5$b47$1@mail.cn99.com...
> "Yan ZHANG" <buaanupt@sina.com> wrote in message
> news:33aanoF3tc0isU1@individual.net...
>> Thank you very much for your comments. do you mind give some sample
>> source
>> code for this? Thanks a lot!
>>
>>
>> "Mole Wang" <molewy@yahoo.com.cn> wrote in message
>> news:cqos0s$aji$1@mail.cn99.com...
>> > bArray in your code is a definition, while CA is a declaration of a
>> > class.
>> > So, what's your meaning?
>> > I guess you want to get a instance of CA, which has the member b1
>> identical
>> > with bArray[1]. Simply, you can define a constructor for CA to initiate
>> its
>> > member b1. Whenever you want a object of CA, you just pass bArray[1] to
>> the
>> > constructor.
>> > bArray does not have to be a global variable.
>> >
>> >
>> > "Yan ZHANG" <buaanupt@sina.com> wrote in message
>> news:33a98oF3uajuoU1@individual.net...
>> > > In the following source code,
>> > > class CA
>> > > {
>> > >     CB b1;
>> > >
>> > >     void funca()
>> > >     {
>> > >      b1.funcb();
>> > >     };
>> > > ......
>> > > };
>> > >
>> > > void main
>> > > {
>> > >     CB bArray[6];
>> > > ...
>> > > }
>> > >
>> > > I am hoping that, in class CA, b1 is exactly same as bArray[1] in the
>> main
>> > > program. That means, for funca in CA, b1.funcb() is same as
>> > > bArray[1].funcb().
>> > >
>> > > The only approach i can think about is defining bArray as a global
>> variable.
>> > > Any other techniques? Thank you very much.

Don't top-post.  Rearranged.

> class CA {
>    CB b1;

That should be

CB &b1;

if you don't want to copy the object.

> public:
>    CA(const CB &b) : b1(b) {}
>    void funca() {
>        b1.funcb();
>    }
> };
> void main()

main() ALWAYS returns an int.

int main()
> {
>    CB bArray[6];
> .................
>    CA ca(bArray[1]);
> }
> CB must have a well-defined copy constructor.
> I hope this is helpful.

Jonathan


 0
Reply jonathanmcdougall2 (279) 12/27/2004 8:00:55 PM

5 Replies
30 Views

Similar Articles

12/13/2013 12:29:54 AM
page loaded in 35672 ms. (0)

Similar Artilces:

I want to create a forum for software testing. The reason to do this when there are thousands of this kind of forums is I want to make my own forum more informative and well- organized. My ideas are when a new thread has grown up in the forum, forum administrators (currently myself) should compose the thread into an essay with all information involved. Thus the contents in the forum will be more tidy and easy to use. And in the future, I will create a tool to assist the composing. Do you think the idea a little attractive, and do you want to help? You can go to http://tester.beijingin...

Dear All, We major in computational electromagnetics. Our research object is to develop efficient algorithms to model electromagnetic waves in complex media. After years of reserach, we developed some good algorithms. We tried to commercialize our research. So we started a software project a year ago. We hired two guys. One worked on GUI, and the other on Kernel. We hoped to finish the project in three months. But the results was not as we expected. Even now, the project is not finished. We just have a coarse version to run some simple cases. And the code is full of bugs and bad smells (repe...

Hi all, Now, I am trying to using Jroute2 to do some routing things. But I am blocked by some questions. 1\ find all the connections to an output of a slice, for example, all the connections to CLB(4,0,S0_XQ), 2\record all the sinks of the src:CLB(4,0,S0_XQ) 3\ using reverseUnroute to unroute all these connections. 4\ rebuild all the connections to a new src CLB(4,2,S0_XQ) I have done the first three steps successfully, but in the forth step, I find something unusual: there used to be a connection form CLB(4,0,S0_XQ) to CLB(4,3,S1_F1), but after I rebuild the connection to a new src CLB(4,2,...

can anyone suggest a forrum where I can ask about the AJAX library called Prototype?
I was reading the article over 24 Ways (http://24ways.org/advent/easy-ajax-with-prototype) and saw this example of using Prototype: function greet(){ var url = 'greeting.php'; var pars = 'greeting-name='+escape(\$F('greeting-name')); var target = 'greeting'; var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars}); } Which I tried to copy on my own page but I could not get it to work. I'm calling a PHP script that says simply echo "working"; simple.just a test This is suppose to work on when pe...

Thank you, thank you, THANK YOU Emily Jackson (Was RE: Looking for IE (Mac) 4 or 4.5)
My original message is long gone, and even your response has been deleted from the server I am on, but since I forwarded your message to my mailbox, I still have the links you posted. And THEY WORK!. Thank you so much. You have made me, and my friend with the old PPC (and a blank HD) very happy. Dave db5151@hotmail.com ...

thanks
letter of thanks to RedGrittyBrick for the help he extended me regarding nested layout managers. the sample source code really helped me in understanding how to nest layout managers. the main program to run the application was too advance for me though, but i'll decode it anyway as i learn more. thank you again. -wee ...

THANK YOU!
When I started my diploma thesis (final year project) 5 months ago I had absolutely no experience with Matlab. So I was glad to get your support to learn it. At the end, I could actually help other people with their easy questions... Now my thesis is finished and I just wanted to say a big THANK YOU for all your help!!! You guys are great! :-) ...

Thank you!!!
Thank you, Pythonistas. You gave me a medium to express myself. What is Fender to Jimi, or color to Monet, Python is for me. My thoughts are flowing naturally with you, Python. What is "Voodoo Chile" to Jimi, that's short, elegant and working ZEN-code in Python for me. Truly a freeing, non-linear and transcendent(*) experience, yours MK (*) Those excit�ng, legendary days when I implemented a paint program in 6502 assembler, and a CAD/CAM program in Turbo Pascal. And then 10 years of IT toiling... Am I loosing my faith? But programming is fun, again!!! PYTHON!! PYTHON!! P...

Thanks.....
Thanks much for your reply. It also works for me... :) eeyimaya wrote: > Thanks much for your reply. It also works for me... :) - do you mean "Struts....I18N and encoding" thread, or what ? eeyimaya <eeyimaya@hotmail.com> scribbled the following: > Thanks much for your reply. It also works for me... :) Glad I could help! Wait, what did I do? -- /-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\ \-------------------------------------------------------- rules! --------/ "Immanuel Kant but Genghis Khan." - The Official Graffitis...

Thanks?
Hi -- I've looked everywhere, but I am still lost. Can someone help me out? I've changed my footnotes in the preamble like this: \makeatletter \renewcommand\@makefntext[1]{\noindent{\@thefnmark.~~}#1} \makeatother So that's just the mark, two spaces and then the footnote. Bu if I want to add a thanks, this does not follow the rules. I get an ugly little asterisk, indented, and the thanks text. Is there a quick way to have the thanksnote similar to the footnote -- that is, in my case, normalsize asterisk, two spaces and a thank you? Thank you! -- Hans In article <4a1...

thanks
hi Bart Cremers Thank q sir my problem has been solved ...

suggestions?
Hello, I have to get euro prices in a dialog. My solution would be a text field initially filled only with an euro sign (undeleble) that accept only digits, an optional comma and optional 1 or 2 digits for cents. Even if the field is left blank, I want to check all data (there are also other components) when the user push an OK button. How can I do this? I am a bit confusing with JFormattedTextFields, JTextFields, NumberFormat and DecimalFormat classes. Thanks, Gaetano <gaetanoortisi@yahoo.it> wrote in message news:1142199267.915920.282230@e56g2000cwe.googlegro...

Thank you!
Thank you Quitchat and Touffy for the rapid feedback! Yes, it does work fine in Firefox afterall! When I saw your surprising responses, I checked my FF version. It was 1.0.6, so I uninstalled and installed the newest (1.5.0.2) and it works! Hurray! Thanks for the quick feedback, Ann Ooops... This last post should go on this thread: http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/8522ab6afbcc606a/ebf227adff232b1d#ebf227adff232b1d ("Resize table problem in Firefox for Web App", one post below this one...) I accidentally posted it in its own thread. :(...

IT- No thanks !
Worth the effort to test the Groups sincerity- virtually NIL ! Stay with PORN guys, the rest is beyond you ! You fall into the weido and "net junkie" catogory, same as APPLE DISCUSSION and CoolRunning. I will keep on looking ! Ernie Lee In article <1151519542.637734.37320@i40g2000cwc.googlegroups.com>, erniemac@comcen.com.au wrote: > Worth the effort to test the Groups sincerity- virtually NIL ! <http://www.rosswalker.co.uk/movie_sounds/sounds_files_20060519_3205813/p ulp_fiction/english.wav> (not safe for work) In article <1151519542.637734.37320@i40g2000...

Thanks
Thanks to all those kind people who offered suggestions to sort out the email glitch I reported on 9 March. I tried out many of them and my computer seems to have righted itself. But I was worried that my computer seemed so vulnerable, so I've invested in a new iMac and would be interested to receive suggestions about methods (free or pay- for) blocking viruses and other nasties. I know that Macs supposedly don't get viruses but what happened to my computer looked rather like one! One other thing. I'm puzzled to know how Oxford Macug members recieve notice of meetings, as I can&#...

Thank You to All !
Tahnk you to all of you who reply to me : each idea helps me very much !!! Sincerly, Nathalie ...

Suggestion
Hello there, i'm trying to implement "osnaps" in my view (2d or 3d). Osnaps allow to force the input to a point when the mouse is near a sensitive vertex (i.e. start or end point of a line) I have found 3 possible methods, but I don't know which one could be the most efficient. - Get all possible osnap points and compare them in World space with the current mouse position (not so good). - Get all possible osnap points and compare them in View space with the current mouse position (better) - Use opengl selection mode with a big enought viewport. Anyway I should do selection ...

I am thankful to all
Hi Friends Last week i posted following questions related to C Language in this group 1> What is the difference between the standard C language and Non standard C language ? 2> which is better C Lanugage, C under Linux/ Unix or C under windows/ DOS ? 3> Under Linux Platform why Conio.h and and many other header files are not available in C Language Compiler ? 4> Which is latest version of C ? and who makes changes to the language Syntax and Add new features or upgrade the language ? I am thankful to all those members who posted reply to these questions and tried to solve my ...

A thank-you!
Five years ago this month I started writing for Micro Mart; it was a retro computer column I had undertaken, but unlike others, I was given a free hand as to what to write about. So, I choose to focus on home- brew software development, new(ish) hardware, hardware hacks and anything else "geeky" that interested me, and importantly not what would be considered as "commercial retro". So, I'd just like to say a thank-you to all of those people who work for free and have helped me fill the pages over the years. You know who you are. It has really been your column, and I...

What you suggest?
Hello group, I'm going to buy a board so I found few boards on the following website. I don't know where I'm going but what I can tell you is where I am. I'm new to VHDL and Embedded Systems field. Currently learning VHDL and Verilog then I must get familiar with FPGA. I thought somebody from this group could help me to figure out which board is good for me. At least it must come handy for 2 - 3 years. http://www.xess.com/ or http://www.xilinx.com/products/silicon_solutions/fpgas/spartan_series/index.htm thank you. amit Amit wrote: > I'm going to buy a board ...