473,466 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please comment on the code

sci
For B to call back a member of A, the code is design as:

class A;

class B
{
A* p;
public:
void Init(void* m) { p = (A*)m; }
void docallback();
};
class A
{
B b;
public:
A() { b.Init(this); }
void dowork() { }

};
void B::docallback()
{
((A*)p)->dowork();
}

Thanks!
Jul 22 '05 #1
1 1267
sci wrote:
For B to call back a member of A, the code is design as:

class A;

class B
{
A* p;
public:
void Init(void* m) { p = (A*)m; }
C-style casts are evil. Why didn't you just make Init take a A*?
void docallback();
};
class A
{
B b;
public:
A() { b.Init(this); }
void dowork() { }

};
void B::docallback()
{
((A*)p)->dowork();
Why are you casting p to the type it already is?
}


-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #2

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

Similar topics

0
by: Al Tobey | last post by:
DBIx::Config is a new module I've written to simplify connecting to databases and passing the resulting handles between packages. Before uploading to CPAN, I'd like to see what people around here...
13
by: Christoph Brunner | last post by:
Hi, on the sun homepage i had submit to the bugparade a request for feature enhancement for the JAXB API. After a period of time sun called me to post my request to a newsgroup an get comments...
6
by: Vidya | last post by:
Hi, Is there an option in Microsoft Visual C++ 6.0 to comment/uncomment chunks of code ? Thanks, Vidya. ps: apologies if wrong group.
36
by: amanayin | last post by:
As i am not at school for c programming can you please tell me if there is anything bad about this program /* EX4-9.C FUNCTION TO CALL OTHER FUNCTIONS */ #include<stdio.h> float div(float...
2
by: Just Me | last post by:
When I print QueryPageSettings gets called a few times before PrintPage is called. I just occurred to me that the problem may be that I do AddHandler each time I print. Is that wrong? If...
7
by: manoj1978 | last post by:
Hi All, I wrote the following to convert an integer to its string representation from base -32 to 32(32 since strtoul takes 32). Used recursion so as not to crowd the logic. Please Comment on...
58
by: manoj1978 | last post by:
Hi All, I wrote the following to print an integer in its string representation for base -36 to 36. Please comment on this code. #include <iostream> #include <string> using std::abs; using...
12
by: MQ.john | last post by:
//Working Example: #include <stdio.h> #include <time.h> int main () { time_t rawtime; /* define rawtime as time_t */ time ( &rawtime );
3
by: Martin P. Hellwig | last post by:
Hi all, I've been toying with python for about two years now. Not every day, just when I encounter something in my job (sysadmin) repetitively dull. The amazing thing is that like any other...
7
by: chris52672 | last post by:
I am trying to resize form1 aka (CipherForm) while the program is running. I have Visual Studios 2003. I have tried private void CipherForm_Load(object sender, System.EventArgs e) {...
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
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,...
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
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,...
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...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.