faq why I see it?

F

fcvcnet

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 <CSegment> m_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.
 
F

fcvcnet

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.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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.
 
F

fcvcnet

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ée Lajoie, Barbara E. Moo 12.6. static
Class Members

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

I used it ,
vector <Account> ac1(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.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

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ée Lajoie, Barbara E. Moo 12.6. static
Class Members

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

I used it ,
vector <Account> ac1(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.
 
F

fcvcnet

OK, thank you very much.

"Erik Wikström" <[email protected]>
??????:[email protected]...
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ée Lajoie, Barbara E. Moo 12.6. static
Class Members

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

I used it ,
vector <Account> ac1(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.
 
F

fcvcnet

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
....
....
 
F

fcvcnet

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.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

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.
 
F

fcvcnet

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öm" <[email protected]>
??????:[email protected]...
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.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

"Erik Wikström" <[email protected]>
??????:[email protected]...


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.
 
F

fcvcnet

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.
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?
 
D

Default User

Erik Wikström 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.


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
 
M

Marcus Kwok

fcvcnet said:
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.
 
M

Marcus Kwok

fcvcnet said:
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.
 
G

Grizlyk

fcvcnet said:
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/
 
F

fcvcnet

Grizlyk дµÀ:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top