473,473 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

number of children exist?

Hi
I have a mother class, and a child class. Can i know how man object
of child exist from the mother class?

thanks
from Peter (cm****@hotmail.com)

Aug 28 '06 #1
5 1553
cm****@hotmail.com wrote:
Hi
I have a mother class, and a child class. Can i know how man object
of child exist from the mother class?
The "mother class" (whatever you mean by it) should have either a record
or a memory about giving birth to each "child". Counting the records or
remembering (extracting from memory) should give you the child count.

In any way, C++ has no concept of "mother" or "child". What exactly do
you mean by those?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 28 '06 #2
cmk128 wrote:
I have a mother class, and a child class. Can i know how man object
of child exist from the mother class?
Please post some code. The jargon "mother" and "child" can mean many
different things.

If you mean "base" and "derived classes", you can't know the number.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Aug 28 '06 #3
<cm****@hotmail.comwrote:
I have a mother class, and a child class. Can i know how man[y]
object[s]
of child exist from the mother class?
Add a protected data member to the base class. In the constructor for the
derived class, increment the count contained in the parent. If you're a
worry wart you can make it more complicated.
Aug 28 '06 #4

osmium 寫道:
<cm****@hotmail.comwrote:
I have a mother class, and a child class. Can i know how man[y]
object[s]
of child exist from the mother class?

Add a protected data member to the base class. In the constructor for the
derived class, increment the count contained in the parent. If you're a
worry wart you can make it more complicated.
Thanks osmimum
Instead of a count, can i add give the pointer of the current
object of the drived class to it's parent class? So the parent class
can reference all their child class's object?

thanks
from Peter

Aug 29 '06 #5
<cm****@hotmail.comwrote:
I have a mother class, and a child class. Can i know how man[y]
object[s]
of child exist from the mother class?

Add a protected data member to the base class. In the constructor for the
derived class, increment the count contained in the parent. If you're a
worry wart you can make it more complicated.
Instead of a count, can i add give the pointer of the current
object of the drived class to it's parent class? So the parent class
can reference all their child class's object?

I don't know of any reason that couldn't be done. It's getting complicated
enough that I would put a member function in the base class to handle the
details of adding. The function would add the newly received pointer to a
stack or vector of such pointers.
Aug 29 '06 #6

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

Similar topics

1
by: Matt | last post by:
I want to get the number of children of a given element. Below is my code attempt and the xml sample file. The caller is getElementChildNumber("persons");, I expect to get 2. Since there are 2...
1
by: Kroum Grigorov | last post by:
Hi all I'm planing to use the combination CreateProcess DEBUG_PROCESS so that being sure that my child process (includin all its children) will die when the parent dies. Do there exist any...
1
by: Todd Cary | last post by:
In my previous post, I stated that some JavaScript I inherited does not work in Firefox but does work in IE 6 . I have now isolated a line where it fails in Firefox; the line with the property of...
6
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... ...
2
by: David Hubbard | last post by:
I have an asp.net 2.0 site I am developing. On one page I need to show a family with their children. I want to display info on that page about each child. I created the page and then moved the...
5
by: r_topor | last post by:
As of PHP 5.1, why aren't there functions that return a node's children, a node's first/last/nth child, a node's parent/previous sibling/next sibling, etc., as in the DOM specification? How are...
7
by: Thierry Lam | last post by:
I have the follownig codes: <html> <head> <title>Simple doc</title> </head> <body> <script type="text/javascript"> function greet() {
15
by: CI | last post by:
I have the following XML file <Book> <Chapters> <Chapter number="1"/> <Chapter number="2"/> </Chapters> <Colors> <Color RGB="255"/> <Color RGB="211" name="Red"/>
5
by: rhepsi | last post by:
hii all, i have two forms, worker search form and childsearch form.. in worker search form, i have a button.. search child and textbox... number of children
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
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...
1
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
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 projectplanning, coding, testing,...
1
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?

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.