473,322 Members | 1,755 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,322 software developers and data experts.

implementing Java's Observable in C/C++?

I have to convert some existing Java code into C/C++. One of the
Java classes implements Observable. Can someone suggest how
I might write this in C/C++? I'm thinking I would need something
like function pointers, but I've never used those... Thanks for
any help.

Jul 22 '05 #1
2 1918
Digital Puer wrote:
I have to convert some existing Java code into C/C++. One of the
Java classes implements Observable. Can someone suggest how
I might write this in C/C++? I'm thinking I would need something
like function pointers, but I've never used those... Thanks for
any help.


Why would you need function pointers?

Interfaces and base classes can be translated into C++ fairly directly.
Use std::vector to hold your observables and iterate through them when
doing notification.

I don't see where your issue is - I'd do this in C++ in almost exactly
the same way I'd do it in Java (this is a design pattern, not a language
issue)

Peter.

Jul 22 '05 #2
Digital Puer wrote:
I have to convert some existing Java code into C/C++. One of the
Java classes implements Observable. Can someone suggest how
I might write this in C/C++? I'm thinking I would need something
like function pointers, but I've never used those... Thanks for
any help.


Do you know how to implement the event/listener pairs in Java from scratch?
Do the same with C++. If you aren't threading, then you don't need to
worry about /synchronized/ methods. Use javap on the commandline to get a
clear view of the class's interface.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #3

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

Similar topics

4
by: Murat Tasan | last post by:
i am implementing a custom version of the java.util.Map interface. my custom version does some encryption stuff when making modifications to the map via one of the 4 modification methods (put,...
0
by: Martin | last post by:
Hi All, I am a relative newbie to Java / Applets, but am despirately after some help ! I have got the following code, which is basically a listing with button items along the sides, allowing...
2
by: Digital Puer | last post by:
I have to convert some existing Java code into C/C++. One of the Java classes implements Observable. Can someone suggest how I might write this in C/C++? I'm thinking I would need something like...
4
by: DaKoadMunky | last post by:
<CODE> #include <iostream> using namespace std; int Foo(int x,int y) { int result = x; result*=y; result+=y;
13
by: interec | last post by:
I have some code in Java that I need to translate into C++. My Java code defines a class hierarchy as follows: // interface IA public interface IA { public abstract void doA(); } //...
4
dmjpro
by: dmjpro | last post by:
plz explain me those two Class and Interface ... give me sample code or good link so that i can learn .... about these things .... and also explain why it is in java ..... thanx in advance...
0
dmjpro
by: dmjpro | last post by:
here is my code .... import java.util.*; class Observer1 implements Observer { public void update(Observable observed,Object o) { System.out.println("Observer1 update method: " + o); }
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
4
by: Mohamed Mansour | last post by:
Hello, What is the purpose of implementing the Observer Pattern if we can trigger an event easily? For example (from books), You have a "Forecaster" which notifies "Observable" when a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.