473,789 Members | 2,773 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 1012
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
2774
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
1613
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
1769
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
1803
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
2273
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
2352
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
1712
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
1494
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
1960
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
2424
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
9666
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
10412
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
10200
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...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
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 we have to send another system
2
3703
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.