473,411 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

How to communicate between different classes?

I have several classes build in one project. Class A.functionA()
need call Class B.functionB(parameters...).
Do I have to create an instance of B inside the Class A source code?
I want the implementation of all the classes (A, B, C...) are independent from each other. But each class can call other class's function with some parameters. If I create every other class instances(B, C, D...) in one class (A) the data of each class instance can not be synchronized.
Is there a better way to do that?
May 4 '07 #1
3 4903
AdrianH
1,251 Expert 1GB
I have several classes build in one project. Class A.functionA()
need call Class B.functionB(parameters...).
Do I have to create an instance of B inside the Class A source code?
I want the implementation of all the classes (A, B, C...) are independent from each other. But each class can call other class's function with some parameters. If I create every other class instances(B, C, D...) in one class (A) the data of each class instance can not be synchronized.
Is there a better way to do that?
There are many ways of synchronising between class instances. But what I am gathering from you question is that I think you are confusing classes with objects, and you wouldn't be the first.

A class is a conceptualisation of what an object can do, and what it is composed of. An object is a concrete instance of the class, upon which you can do the stuff you described in your class.

Where you create the instances is dependent upon what you are trying to do. Perhaps a bit more detail would clarify things.


Adrian
May 4 '07 #2
Thanks you. I think I should express myself more clearly.
The project consists of several modules. I designed every module as a class.
The application call class A.functionA( parameter1, ...) and the A.functionA() calls class B.functionB(parameter1, newparameter1, ...).

The application need only create an object of class A, not any other classes(B,C,...).

How can I do that in the easiest and fastest way?
May 4 '07 #3
AdrianH
1,251 Expert 1GB
Thanks you. I think I should express myself more clearly.
The project consists of several modules. I designed every module as a class.
The application call class A.functionA( parameter1, ...) and the A.functionA() calls class B.functionB(parameter1, newparameter1, ...).

The application need only create an object of class A, not any other classes(B,C,...).

How can I do that in the easiest and fastest way?
If I understand you correctly (which I’m not sure if I do), your app will create an instance of A and call a function. That function will then create an instance of B or C and call one of their functions.

Now, will the instance of B or C need to talk back to the instance of A? If so, you are going to have to pass that instance on to B or C. That or you have a global instance of A (not recommended except for under certain circumstances).

Basically, for an instance to ‘talk’ to an instance, the first instance must have a pointer or reference to the second instance.

Does this make sense to you?


Adrian
May 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Joakim Persson | last post by:
Hello all. I am involved in a project where we have a desire to improve our software testing tools, and I'm in charge of looking for solutions regarding the logging of our software (originating...
3
by: Jay Patel | last post by:
Hello, I need to write visual basic.net code to interface with a Mettler Toledo Shipping Scale that interfaces with a PC via USB or a serial port. I have seen example code on how to communicate...
11
by: kd | last post by:
Hi All, Can anybody suggest as to what is the best way communicate between 2 applications residing on the same machine? Thanks. kd
3
by: Ann Huxtable | last post by:
Hi, I am developing a C# front end. But my backend app server is JBoss. I want to know how I can communicate with the backend (maybe using System.Net.WebClient classes?). A search on Google does...
4
by: cantatahost | last post by:
Hello, Likely this has been asked before... We have a library (in DLL form) that we distribute. The interface to the library is all C, but within the library it uses C++ in many places. ...
4
by: The Frog | last post by:
Hi Everyone, I may be out of my depth here but I will ask anyway. Is it possible to communicate with Activesync, so that for example, I have a series of stored text files, and I want to push the...
3
by: SQACSharp | last post by:
Hi, I need to transfer text (or maybe binary) data from one .net application to another .net application. What is the best way to do this since it's on the same computer and both application...
8
by: michelqa | last post by:
Hi, I need to communicate between many C# applications. is tcp socket is the best way to do this? Only the main application that send the initial request can be a remote application in a...
9
by: Johnny E. Jensen | last post by:
Hello NG I have two applications. App1: Database application. Inserts/updates data to database. App2: Notifier: The notifier checks if a record has been created or modified, by loading the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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
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
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...

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.