C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Two objects created in a Single class

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
2005
Guest





PostPosted: Sat Oct 28, 2006 6:29 am    Post subject: Two objects created in a Single class Reply with quote



Hi

I have a situation that I created two objects in a Single class, say

CAll All_A, All_B;

I can access the public functions within them without the "."
operation, say public function Display(), Term() ; inside Display(), I
can do Term() { not All_A.Term() } since they are member functions.

The issue is I have All_A & All_B - how do I differentiate them?

Am I supposed to do
All_B.Term() just to differentiate them?

Thanks
Back to top
David Harmon
Guest





PostPosted: Sat Oct 28, 2006 7:31 am    Post subject: Re: Two objects created in a Single class Reply with quote



On 27 Oct 2006 18:29:54 -0700 in comp.lang.c++, "2005"
<uws2003 (AT) yahoo (DOT) com> wrote,
Quote:
Hi

I have a situation that I created two objects in a Single class, say

CAll All_A, All_B;

I can access the public functions within them without the "."
operation, say public function Display(), Term() ; inside Display(), I
can do Term() { not All_A.Term() } since they are member functions.

The issue is I have All_A & All_B - how do I differentiate them?

Am I supposed to do
All_B.Term() just to differentiate them?


When you call Term() inside CAll::Display(), it is the same as
this->Term(). It is called as a member function of the same object.
So All_A.Display() will end up calling Term() upon All_A, and
ALL_B.Display() will end up calling Term() upon All_B.

As soon as you have three objects you had better start thinking
about std::vector<CAll>.
Back to top
2005
Guest





PostPosted: Sat Oct 28, 2006 7:42 am    Post subject: Re: Two objects created in a Single class Reply with quote



David Harmon wrote:
Quote:
On 27 Oct 2006 18:29:54 -0700 in comp.lang.c++, "2005"
uws2003 (AT) yahoo (DOT) com> wrote,
Hi

I have a situation that I created two objects in a Single class, say

CAll All_A, All_B;

I can access the public functions within them without the "."
operation, say public function Display(), Term() ; inside Display(), I
can do Term() { not All_A.Term() } since they are member functions.

The issue is I have All_A & All_B - how do I differentiate them?

Am I supposed to do
All_B.Term() just to differentiate them?


When you call Term() inside CAll::Display(), it is the same as
this->Term(). It is called as a member function of the same object.
So All_A.Display() will end up calling Term() upon All_A, and
ALL_B.Display() will end up calling Term() upon All_B.

Am I right to assume that inside the member function, I call
ALL_B.Display() & All_A.Display() since there 2 objs ( and it would be
redundant if there are only one object ).
Quote:

As soon as you have three objects you had better start thinking
about std::vector<CAll>.
Back to top
David Harmon
Guest





PostPosted: Sat Oct 28, 2006 9:10 am    Post subject: Re: Two objects created in a Single class Reply with quote

On 27 Oct 2006 19:42:07 -0700 in comp.lang.c++, "2005"
<uws2003 (AT) yahoo (DOT) com> wrote,
Quote:
When you call Term() inside CAll::Display(), it is the same as
this->Term(). It is called as a member function of the same object.
So All_A.Display() will end up calling Term() upon All_A, and
ALL_B.Display() will end up calling Term() upon All_B.

Am I right to assume that inside the member function, I call
ALL_B.Display() & All_A.Display() since there 2 objs

I don't know; what are you trying to accomplish? I certainly don't
see any reason to call both of them from within some other member
function, but you might have a reason.

Quote:
( and it would be redundant if there are only one object ).

No, with only one object you certainly cannot call functions of two
objects.

Post a small but complete compilable sample of the code you are
trying to use.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.