473,503 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two objects created in a Single class

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

Oct 28 '06 #1
3 1107
On 27 Oct 2006 18:29:54 -0700 in comp.lang.c++, "2005"
<uw*****@yahoo.comwrote,
>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>.

Oct 28 '06 #2

David Harmon wrote:
On 27 Oct 2006 18:29:54 -0700 in comp.lang.c++, "2005"
<uw*****@yahoo.comwrote,
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 ).
>
As soon as you have three objects you had better start thinking
about std::vector<CAll>.
Oct 28 '06 #3
On 27 Oct 2006 19:42:07 -0700 in comp.lang.c++, "2005"
<uw*****@yahoo.comwrote,
>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.
>( 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.

Oct 28 '06 #4

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

Similar topics

16
3288
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically...
48
3426
by: Andrew Quine | last post by:
Hi Just read this article http://www.artima.com/intv/choices.html. Towards the end of the dicussions, when asked "Did you consider including support for the concept of immutable directly in C#...
4
1804
by: Ashura | last post by:
H I want to make a project where one or more object could be shared between 2 applications For example : the first application create a connection to a web-service, this connection is stored in...
38
3684
by: Radi Radichev | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
2
1816
by: headware | last post by:
I am new to 3-tiered design and am in the process of designing an application that will work with ASP.NET as well as Windows Forms (and possibly with a PDA of some sort down the road). My question...
2
1983
by: Chris | last post by:
Hi, I am building a single webform/webpage asp.net application using VB.NET. I have created lots of classes for this web application. On page load I use a facade controller pattern class to...
2
1610
by: Fish | last post by:
I have been researching the correct way to organize my solution so that it makes best use of VB.NET inherent ability to manage resources such as objects. My solution contains 2 projects and the...
7
1718
by: MariusI | last post by:
Are objects implicitly stored in the TLS of the currently running thread? When creating multithreaded applications i get errors when accessing data from a different thread than the thread used to...
15
7554
by: shuisheng | last post by:
Dear All, Assume I have a class named Obj. class Obj { }; And a class named Shape which is derived from Obj. class Shape: public Obj
15
3502
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
0
7083
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
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.