473,406 Members | 2,713 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,406 software developers and data experts.

Incrementing using ....

Hi

I have a "private" member "mSize" & "public" function Kite( ).

I want to increment it by 1 everytime it is in the Kite( ).

It appears that the increment disappears as it re-enters Kite( ) the
second time.

So the most I had was mSize =1 (the class initializes to mSize =0).

Is this expected?

Is there a way I can do this?

Thank you

Oct 26 '06 #1
6 1539

2005 wrote:
Hi

I have a "private" member "mSize" & "public" function Kite( ).

I want to increment it by 1 everytime it is in the Kite( ).

It appears that the increment disappears as it re-enters Kite( ) the
second time.

So the most I had was mSize =1 (the class initializes to mSize =0).

Is this expected?
Not by you, it would seem. Nobody else has any expectations one way or
the other since nobody else can see your code.
Is there a way I can do this?
I expect so.

The FAQ tells you how to post questions about problem code.
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Follow *all* those guidelines and you will get the help you want.

Gavin Deane

Oct 26 '06 #2
2005 wrote:
It appears that the increment disappears as it re-enters Kite( ) the
second time.
Yes, it disappeared. I can't see it.

--
Salu2
Oct 26 '06 #3

2005 wrote:
Hi

I have a "private" member "mSize" & "public" function Kite( ).

I want to increment it by 1 everytime it is in the Kite( ).

It appears that the increment disappears as it re-enters Kite( ) the
second time.

So the most I had was mSize =1 (the class initializes to mSize =0).

Is this expected?

Thank you
Thats, nice. Share the code or a reconstruction that is compileable.
Otherwise, you are out of luck.

Oct 26 '06 #4
What you could do is make the mSize variable static so that only one
instance of it is created. Inside of the function Kite increment the
value of mSize, this way multiple objects of your class will share the
same mSize variable.

On Oct 26, 5:34 pm, "Salt_Peter" <pj_h...@yahoo.comwrote:
2005 wrote:
Hi
I have a "private" member "mSize" & "public" function Kite( ).
I want to increment it by 1 everytime it is in the Kite( ).
It appears that the increment disappears as it re-enters Kite( ) the
second time.
So the most I had was mSize =1 (the class initializes to mSize =0).
Is this expected?
Thank youThats, nice. Share the code or a reconstruction that is compileable.
Otherwise, you are out of luck.
Oct 26 '06 #5
"2005" <uw*****@yahoo.comwrote:
I have a "private" member "mSize" & "public" function Kite( ).

I want to increment it by 1 everytime it is in the Kite( ).

It appears that the increment disappears as it re-enters Kite( ) the
second time.

So the most I had was mSize =1 (the class initializes to mSize =0).

Is this expected?
Your code does exactly what it you wrote it to do, but it doesn't do
what you want it to do. Therefore, you need to write it to do what you
want, then when it does what you wrote, it will do what you expect.
Is there a way I can do this?
Yes.

I appreciate that you are not simply posting your homework assignment
and asking someone to do it. That really is a good trait. At the same
time, we can't help you if you give us too little information.

Check out the code below, really study it and tell me if it does what
you want done.

class MyClass {
int mSize;
public:
MyClass():mSize(0) { }
int size() const { return mSize; }
void Kite() { ++mSize; }
};

int main() {
MyClass object;
assert( object.size() == 0 );
object.Kite();
assert( object.size() == 1 );
object.Kite();
assert( object.size() == 2 );
}

--
To send me email, put "sheltie" in the subject.
Oct 27 '06 #6
[please don't top post] reorganized...
>
On Oct 26, 5:34 pm, "Salt_Peter" <pj_h...@yahoo.comwrote:
2005 wrote:
Hi
I have a "private" member "mSize" & "public" function Kite( ).
I want to increment it by 1 everytime it is in the Kite( ).
It appears that the increment disappears as it re-enters Kite( ) the
second time.
So the most I had was mSize =1 (the class initializes to mSize =0).
Is this expected?
Thank youThats, nice. Share the code or a reconstruction that is compileable.
Otherwise, you are out of luck.
Jo*************@gmail.com wrote:
What you could do is make the mSize variable static so that only one
instance of it is created. Inside of the function Kite increment the
value of mSize, this way multiple objects of your class will share the
same mSize variable.
Thats not neccessarily the right strategy since then *all* the objects
have the same static "mSize". We have no knowledge about what Kite() or
mSize are attempting to solve since we can't see the problem.

Oct 27 '06 #7

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

Similar topics

3
by: Mothra | last post by:
Here's what I'm trying to do (kill off old Unix logins): --------------------- $i=0; while (<$who>) { chomp($_); my @line = split(/\s+/, $_); # Split it into an array next unless ($line...
2
by: brian | last post by:
Hi, before coming to .NET, I utilized regular expressions mostly in JScript / JavaScript and also in my favorite text editor: TextPad (www.textpad.com) I don't know about JScript/JavaScript, but...
10
by: Antanas | last post by:
The problem is that when AddID is used multiple times in the same select statement, it returns the same value in all places. How could I force function AddID to increment OBJECTID sequence? Here...
2
by: Payson Books | last post by:
Where can I find some info on grabbing the recordID of the last record, incrementing it by one, and using the new number in a new record.
26
by: Bas Wassink | last post by:
Hi there, Does the ANSI standard say anything about incrementing variables past their limits ? When I compile code like this: unsigned char x = 255; x++; printf ( "%d\n", x );
53
by: subramanian100in | last post by:
I saw this question from www.brainbench.com void *ptr; myStruct myArray; ptr = myArray; Which of the following is the correct way to increment the variable "ptr"? Choice 1 ptr = ptr +...
3
by: =?Utf-8?B?TWlrZSBL?= | last post by:
I have a Net 2.0 app in VB that has code like this: Dim intA as Integer Dim intB as Integer dim myList as new List(Of String) intA = 10 intB = 20 .... code to fill the list ....
1
by: asandiego | last post by:
Hey guys, this is my first post here but have been checking this site a lot for anything I need. I hope someone can lead me to what I should do or just an idea to what can be done. What I'm...
8
by: arachno | last post by:
My Oracle sequences seem to be auto-incrementing themselves "over time". My row ID's are sequenced like this: 1, 4, 5, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 41, etc I'm using...
9
by: subramanian100in | last post by:
The following portion is from c-faq.com - comp.lang.c FAQ list · Question 6.13 int a1 = {0, 1, 2}; int a2 = {{3, 4, 5}, {6, 7, 8}}; int *ip; /* pointer to int */ int (*ap); /* pointer to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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
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...
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...

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.