By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

faq why I see it?

P: n/a
Hi,
As we know, a static member viarable is an object associated with the
class, not with the objects of that class. And when we debug the code, we
can not see the value of the member of some particular class, but to me, I
see it, it puzzled me.
What is wrong with my code?

class CSegment
{
public:
....
private:
....
static unsigned int m_numsegment;

};

CSegment::CSegment(void)
: m_pointlist(0)
, m_index(0)
, m_createdirection(true)
{
}

....

class CborderView : public CView
{
....
private:
....
vector <CSegmentm_mylinelist;
....

};

And when I debug the code , I see the value of m_numsegment in every element
of the m_mylinelist, why?

Thanks a lot.
Mar 14 '07 #1
Share this Question
Share on Google+
17 Replies


P: n/a
And in book C++ Primer, Fourth Edition By Stanley B. Lippman, Josée Lajoie,
Barbara E. Moo 12.6. static Class Members
I try the code , and I can not see the value of the static member of a
class.

"fcvcnet" <fc*****@163.com写入消息新闻:et**********@news.cn9 9.com...
Hi,
As we know, a static member viarable is an object associated with the
class, not with the objects of that class. And when we debug the code, we
can not see the value of the member of some particular class, but to me, I
see it, it puzzled me.
What is wrong with my code?

class CSegment
{
public:
...
private:
...
static unsigned int m_numsegment;

};

CSegment::CSegment(void)
: m_pointlist(0)
, m_index(0)
, m_createdirection(true)
{
}

...

class CborderView : public CView
{
...
private:
...
vector <CSegmentm_mylinelist;
...

};

And when I debug the code , I see the value of m_numsegment in every
element of the m_mylinelist, why?

Thanks a lot.


Mar 14 '07 #2

P: n/a
On 2007-03-14 08:47, fcvcnet wrote:
Hi,
As we know, a static member viarable is an object associated with the
class, not with the objects of that class. And when we debug the code, we
can not see the value of the member of some particular class, but to me, I
see it, it puzzled me.
What is wrong with my code?
Well, it's really up to the debugger vendor to choose what to show and
what not to, the standard does not define such tings. But to me it's
quite normal that you can see the static members of a class, after all
they are a member of the class. Or another way to look at it, the static
member is a member that has the same value in every instance of the
class, except for this peculiarity it's (almost) like any other member.
So it's quite convenient for the debugger to display it as just another
member.

So there's nothing wrong with your code (unless the value of the static
member is different for each object) but rather it's your expectations
of the code that are wrong.

--
Erik Wikstr鰉
Mar 14 '07 #3

P: n/a
Thank you.

But I see this:

m_mylinelist --
--[0]
+ m_pointlist
m_index
...
m_numsegment 5. <--- this is static
member viarabe of class CSegment
--[1]
+ m_pointlist
m_index
...
m_numsegment 5.
--[2]
+ m_pointlist
m_index
...
m_numsegment 5.
.......
I use vs2005, use the same tools, I debug the code of C++ Primer, Fourth
Edition By Stanley B. Lippman, Jos閑 Lajoie, Barbara E. Moo 12.6. static
Class Members

class Account {
public:
....
private:
....
static double interestRate;
....
};

I used it ,
vector <Accountac1(5);
In debug
ac1 --
--[0]
+owner
account
(no static double interestRate )
--[1]
+owner
account
(no static double interestRate )
--[2]
+owner
account
(no static double interestRate )
.......
All I can not see the static member viarable || static double interestRate
|| .

Why?

Thanks you very much.


Mar 15 '07 #4

P: n/a
On 15 Mar, 04:48, "fcvcnet" <fcvc...@163.comwrote:
Thank you.

But I see this:

m_mylinelist --
--[0]
+ m_pointlist
m_index
...
m_numsegment 5. <--- this is static
member viarabe of class CSegment
--[1]
+ m_pointlist
m_index
...
m_numsegment 5.
--[2]
+ m_pointlist
m_index
...
m_numsegment 5.
......
I use vs2005, use the same tools, I debug the code of C++ Primer, Fourth
Edition By Stanley B. Lippman, Jos閑 Lajoie, Barbara E. Moo 12.6. static
Class Members

class Account {
public:
...
private:
...
static double interestRate;
...
};

I used it ,
vector <Accountac1(5);
In debug
ac1 --
--[0]
+owner
account
(no static double interestRate )
--[1]
+owner
account
(no static double interestRate )
--[2]
+owner
account
(no static double interestRate )
......
All I can not see the static member viarable || static double interestRate
|| .

Why?
I recall similar results from some quick testing and I think id
depends on whether the member has been initialized or not. But as I
said, this is something that the devs at MS decided, perhaps you can
find something in the VS documentation.

--
Erik Wikstr鰉

Mar 15 '07 #5

P: n/a
OK, thank you very much.

"Erik Wikstr鰉" <er****@student.chalmers.se>
??????:11**********************@l77g2000hsb.google groups.com...
On 15 Mar, 04:48, "fcvcnet" <fcvc...@163.comwrote:
Thank you.

But I see this:

m_mylinelist --
--[0]
+ m_pointlist
m_index
...
m_numsegment 5. <--- this is static
member viarabe of class CSegment
--[1]
+ m_pointlist
m_index
...
m_numsegment 5.
--[2]
+ m_pointlist
m_index
...
m_numsegment 5.
......
I use vs2005, use the same tools, I debug the code of C++ Primer, Fourth
Edition By Stanley B. Lippman, Jos閑 Lajoie, Barbara E. Moo 12.6. static
Class Members

class Account {
public:
...
private:
...
static double interestRate;
...
};

I used it ,
vector <Accountac1(5);
In debug
ac1 --
--[0]
+owner
account
(no static double interestRate )
--[1]
+owner
account
(no static double interestRate )
--[2]
+owner
account
(no static double interestRate )
......
All I can not see the static member viarable || static double interestRate
|| .

Why?
I recall similar results from some quick testing and I think id
depends on whether the member has been initialized or not. But as I
said, this is something that the devs at MS decided, perhaps you can
find something in the VS documentation.

--
Erik Wikstr鰉

Mar 15 '07 #6

P: n/a
fcvcnet wrote:
OK, thank you very much.
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.html>
Mar 15 '07 #7

P: n/a
I do not know. I do not top-post. If sort by date , my post is at line of
44.
Why?
-------------------------------------------------------------------
No.1
....
....
No.44
faq why I see it? fcvcnet
Re:faq why I see it? fcvcnet
Re:faq why I see it? Erik Wikstr?m
Re:faq why I see it? fcvcnet
Re:faq why I see it? Erik Wikstr?m
Re:faq why I see it? Default user
Re:faq why I see it? fcvcnet
....
....
-------------------------------------------------------------------
All my posts is below and in my question "faq why I see it?".
Do you see my message is top-post?


Mar 16 '07 #8

P: n/a
More, I use Outlook Express.
Maybe some different with yours client.
Maybe I set some wrong with it.
If you know how to set and make outlook express not to top-post, please tell
me .
Thank you very much.
Mar 16 '07 #9

P: n/a
On 16 Mar, 01:59, "fcvcnet" <fcvc...@163.comwrote:
More, I use Outlook Express.
Maybe some different with yours client.
Maybe I set some wrong with it.
If you know how to set and make outlook express not to top-post, please tell
No, you misunderstood, top-posting is when you post the reply above
the message you are replying to. Outlook Express is bad in that sense
since it always places the cursor at the top when replying.

--
Erik Wikstr鰉

Mar 16 '07 #10

P: n/a
Ok, what cliend you use?
I can change mine.
And I realy do not know this, and I do not want to do some wrong in this
groups.
"Erik Wikstr鰉" <er****@student.chalmers.se>
??????:11*********************@n76g2000hsh.googleg roups.com...
On 16 Mar, 01:59, "fcvcnet" <fcvc...@163.comwrote:
More, I use Outlook Express.
Maybe some different with yours client.
Maybe I set some wrong with it.
If you know how to set and make outlook express not to top-post, please
tell
No, you misunderstood, top-posting is when you post the reply above
the message you are replying to. Outlook Express is bad in that sense
since it always places the cursor at the top when replying.

--
Erik Wikstr鰉

Mar 16 '07 #11

P: n/a
On 16 Mar, 08:31, "fcvcnet" <fcvc...@163.comwrote:
"Erik Wikstr鰉" <eri...@student.chalmers.se>
??????:1174029978.621399.13...@n76g2000hsh.googleg roups.com...
On 16 Mar, 01:59, "fcvcnet" <fcvc...@163.comwrote:
More, I use Outlook Express.
Maybe some different with yours client.
Maybe I set some wrong with it.
If you know how to set and make outlook express not to top-post, please
tell

No, you misunderstood, top-posting is when you post the reply above
the message you are replying to. Outlook Express is bad in that sense
since it always places the cursor at the top when replying.
Ok, what cliend you use?
I can change mine.
And I realy do not know this, and I do not want to do some wrong in this
groups.
The client used in of little importance, what matters is that when
replying you remove signatures (and if the post is long) irrelevant
text and write your reply below what you are replying to (which just
just a matter of moving the cursor). Personally I find that
Thunderbird is quite good as a newsreader for windows.

--
Erik Wikstr鰉

Mar 16 '07 #12

P: n/a
The client used in of little importance, what matters is that when
replying you remove signatures (and if the post is long) irrelevant
text and write your reply below what you are replying to (which just
just a matter of moving the cursor). Personally I find that
Thunderbird is quite good as a newsreader for windows.

--
Erik Wikstr鰉
I now just to tell you , now I download a Thunderbird 1.5.0.7. And I
feel it is cool.

Am I right ,this time?

--
fcvcnet
Mar 16 '07 #13

P: n/a
Erik Wikstr鰉 wrote:

The client used in of little importance, what matters is that when
replying you remove signatures (and if the post is long) irrelevant
text and write your reply below what you are replying to (which just
just a matter of moving the cursor). Personally I find that
Thunderbird is quite good as a newsreader for windows.

--
Erik Wikstr鰉

The bit about signatures works better when people have correct .sig
separators. That is, "-- " (dash dash space) on a line with no other
text. This allows many newsreaders to automatically trim .sigs

The reason I bring this up is that yours does not follow this
convention. I suggest looking into that.


Brian
Mar 16 '07 #14

P: n/a
fcvcnet <fc*****@163.comwrote:
More, I use Outlook Express.
Maybe some different with yours client.
Maybe I set some wrong with it.
If you know how to set and make outlook express not to top-post, please tell
me .
It's the default behavior of Outlook Express to quote improperly.
Google for oequotefix.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Mar 16 '07 #15

P: n/a
fcvcnet <fc*****@163.comwrote:
>
>The client used in of little importance, what matters is that when
replying you remove signatures (and if the post is long) irrelevant
text and write your reply below what you are replying to (which just
just a matter of moving the cursor). Personally I find that
Thunderbird is quite good as a newsreader for windows.

--
Erik Wikstr鰉
I now just to tell you , now I download a Thunderbird 1.5.0.7. And I
feel it is cool.

Am I right ,this time?
Almost. You didn't trim Erik's signature, but you trimmed the
attribution line showing what he wrote.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Mar 16 '07 #16

P: n/a

fcvcnet wrote:
>
Hi,
As we know, a static member viarable is an object associated with the
class, not with the objects of that class.
class CSegment
{
public:
...
private:
...
static unsigned int m_numsegment;

};
And when I debug the code , I see the value of m_numsegment in every
element of the m_mylinelist, why?
Because there are no "associated" members of class in C++. Probably you are
mixing interface and implementation. Interface of class contains all public
declared members, including enums, statics, and all inherited public members
of base classes, in spite of their implementation or association.

The following expressions are correct:

CSegment::m_numsegment;

CSegment tmp;
tmp.m_numsegment;

Also it is your debugger's convention, what members of the class must be
displayed for objects.
--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new

"In thi world of fairy tales rolls are liked olso"
/Gnume/
Mar 22 '07 #17

P: n/a
Grizlyk 写道:
fcvcnet wrote:
>Hi,
As we know, a static member viarable is an object associated with the
class, not with the objects of that class.
class CSegment
{
public:
...
private:
...
static unsigned int m_numsegment;

};
And when I debug the code , I see the value of m_numsegment in every
element of the m_mylinelist, why?

Because there are no "associated" members of class in C++. Probably you are
mixing interface and implementation. Interface of class contains all public
declared members, including enums, statics, and all inherited public members
of base classes, in spite of their implementation or association.

The following expressions are correct:

CSegment::m_numsegment;

CSegment tmp;
tmp.m_numsegment;

Also it is your debugger's convention, what members of the class must be
displayed for objects.

Thank you Grizlyk .
Because there are no "associated" members of class in C++.
I do not understand very well.
CSegment::m_numsegment;

CSegment tmp;
tmp.m_numsegment;
Just now , I try a project.

Class my
{
static int m_no;
};

int my::m_no=0;

and I define a array of a[10], I can see every element has a m_no been
displayed. So, it might be
Also it is your debugger's convention, what members of the class must be
displayed for objects.


Mar 26 '07 #18

This discussion thread is closed

Replies have been disabled for this discussion.