473,671 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OOP help needed

Hi,
I have 3 classes
A , B ,C
A makes an object of B with
B b = new B();

B makes an object ob C with
C c= new C();

A and C are WindowsForms

in C i have a listbox with a MouseUp event. when something is selected and
mouse is up then

B must do his method method1() . I dont want to make the method1() static
because than nearly everything becomes static

but how can I make it in class C without making a new object of B?
Nov 16 '05 #1
3 1006
You could create an object that coordinates interactions between
widgets.
This "mediator" object is an intermediary that keeps widgets from
referring to
each other explicitly. Widgets know, and signal, the mediator and the
mediator contains the logic to update the widgets as needed.

The lazy way is for B to register an interest in C c.addNotify(b).

Regards,
Jeff
but how can I make it in class C without making a new object of B?<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #2
I'm not sure if I got what you're looking for. But I take it that you want C
to call a method in B? If so, pass C a reference to B when created so C can
call it

class B {
public test();

public createC() {
C c = new C(this);
}

in C:

class C {
private B b;

C ( B b ) { this.b = b; }

listBox1_MouseU p(...) { this.b.test(); }
};

"Bilo" <ju********@yah oo.com> wrote in message
news:O%******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,
I have 3 classes
A , B ,C
A makes an object of B with
B b = new B();

B makes an object ob C with
C c= new C();

A and C are WindowsForms

in C i have a listbox with a MouseUp event. when something is selected and
mouse is up then

B must do his method method1() . I dont want to make the method1() static
because than nearly everything becomes static

but how can I make it in class C without making a new object of B?

Nov 16 '05 #3
Thx,
your codes makes an error because it try to convert object B to a Object C
and that makes an error.
But it help me . Hasnt the idea to send B with the constructor of class C.
Thx solved my problem.

"Eddie Pazz" <dr****@hotmail .com> schrieb im Newsbeitrag
news:ej******** ******@TK2MSFTN GP10.phx.gbl...
I'm not sure if I got what you're looking for. But I take it that you want C to call a method in B? If so, pass C a reference to B when created so C can call it

class B {
public test();

public createC() {
C c = new C(this);
}

in C:

class C {
private B b;

C ( B b ) { this.b = b; }

listBox1_MouseU p(...) { this.b.test(); }
};

"Bilo" <ju********@yah oo.com> wrote in message
news:O%******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,
I have 3 classes
A , B ,C
A makes an object of B with
B b = new B();

B makes an object ob C with
C c= new C();

A and C are WindowsForms

in C i have a listbox with a MouseUp event. when something is selected and mouse is up then

B must do his method method1() . I dont want to make the method1() static because than nearly everything becomes static

but how can I make it in class C without making a new object of B?


Nov 16 '05 #4

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

Similar topics

0
2766
by: System | last post by:
Hello All, Redhat 9.0 Mysql 3.23.56 ==> Running I want to upgarde to 4.0.13 but this is the error it says: # rpm -Uvh MySQL-server-4.0.13-0.i386.rpm warning: MySQL-server-4.0.13-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5 error: Failed dependencies: libmysqlclient.so.10 is needed by (installed) mod_auth_mysql-1.11-12
8
1605
by: Stephen | last post by:
I am trying to add some code to below to include a datatable and fill the datatable. The reason for doing this is so as I can check to see whether there are any rows returned by the stored procedure. If there are no records returned then this would give me an indicator and I can re-direct the page somewhere more appropriate. Well this is the theory. I have never used datatables before and am not sure how to implemenet what I want so I was...
13
1739
by: Joe Feldman | last post by:
This position is located in the South Bay Area in Northern California. If you are interested please send me your resume in a word .doc so that I can review it. If this does not look like a match, we have over 100 other open positions. Senior Member of Technical Staff/ Principal Engineer- Protocols Infrastructure
0
1796
by: Cindy B | last post by:
Please send your resume and position to Cindy@AtlanticResource.com! I CAN NOT accept candidates that ARE OUTSIDE OF THE US! NO PHONE CALLS PLEASE! Email your resume to me! Position:SQL SERVER/PEOPLESOFT DBA Date: 03/07/05 Location: Richmond, VA Duration: 5 month conract to hire Salary: 65,000-80,000K Contract to Hire 5 months
3
2265
by: Wade | last post by:
I would like to install the .Net 1.1 framework on a Web Server running W2K to be able to run ASP.NET files, but I'm not sure where to find the files I need for the .Net framework. I have ".NET Framework 1.1 Service Pack 1" (NDP1.1sp1-KB867460-X86.exe) and "ASP.NET Security Update for .NET Framework 1.1 SP1" (NDP1.1sp1-KB886903-X86.exe). The SP1 will not install unless 1.1 is already installed (I thought that SP1 was the whole 1.1...
17
2340
by: dingoatemydonut | last post by:
The C99 standard states: "In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no needed side effects are produced (including any caused by calling a function or accessing a volatile object)." Does that mean that in the following code, *p does not have to be evaluated since its side...
5
1708
by: Steve | last post by:
Hi, I am sitting down to design our next set of internal apps. I would like to approach this in a way that would allow me to break logical parts of the application that handle specific tasks into modules. For example, assuming we have 4 main tasks to accomplish: - Printing - Editing - Viewing - Inventory Management
0
1477
by: ultradiv | last post by:
I have a VB.NET application partly built that produces an xml output (just a file at present) I have a .NET webserver and SQLserver 2000 I need to be able to send the xml to the webserver/database (some crunching is needed before the data is stored) The database (stored proc.) will reply with several small pieces of data which need to be sent back to the client app. I am thinking that all of this could be accomplished in one call to a...
28
1930
by: Ian Davies | last post by:
Hello I would appreciate some help from someone who has knowledge of working with css, php javascript and how they interact. Ive been working on a task for the last few days and have started to hit a brick wall. I need general advice on whether I m tackling the problem the correct way and some solutions for my current problems Ive posted my project below where ive detailed the current problems im having...
37
2395
by: C_guy | last post by:
Does anyone know of a (hopefully free) tool that can traverse a project and determine which "#include"s are not needed or needed in every .C file? This would be helpful in removing header inclusions that are redundant and/or unnecessary. Thanks!
0
8474
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8392
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8912
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8669
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.