Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

這樣算不算是BCB的BUG阿

0 views
Skip to first unread message

烏拉諾斯

unread,
Aug 17, 2001, 5:29:29 AM8/17/01
to
※ 引述《WaSiVaG...@zoo.ee.ntu.edu.tw (等你說喜歡我)》之銘言:
> class A {
> const static m=5;
> }
> const int *ptrm = &A::m;
> cout<<*ptrm;
> m不是private的嗎 這樣不就可以被讀出來 是編譯器的bug
> 還是我觀念的問題哩
> 還有如果在class A 裡不要初始m ,而在class外初始化它
> const A::m=5; 編譯器就會說A::m is not accessible
> 我用的是BCB 5 SP1

The private member variable is just accessed by the public member function.
So..It is not BCB's bug.
--
[m※ Origin: 雲林科技大學藍天使 <bbs.yuntech.edu.tw> [From: 140.125.32.51]

等你說喜歡我

unread,
Aug 17, 2001, 6:21:53 AM8/17/01
to
※ 引述《Apya...@bbs.yuntech.edu.tw (烏拉諾斯)》之銘言:
: ※ 引述《WaSiVaG...@zoo.ee.ntu.edu.tw (等你說喜歡我)》之銘言:

: > class A {
: > const static m=5;
: > }
: > const int *ptrm = &A::m;
: > cout<<*ptrm;
: > m不是private的嗎 這樣不就可以被讀出來 是編譯器的bug
: > 還是我觀念的問題哩
: > 還有如果在class A 裡不要初始m ,而在class外初始化它
: > const A::m=5; 編譯器就會說A::m is not accessible
: > 我用的是BCB 5 SP1
: The private member variable is just accessed by the public member function.
: So..It is not BCB's bug.

你好像沒仔細看我的問題內容 const int*ptrm=&A::m;

這樣不是已經讓ptrm得到A:m的address 再dereference

就得到它的值 這樣不算access嗎???
--
[1;31mO [1;32mr [1;33mi [1;34mg [1;35mi [1;36mn [1;31m: [1;36m<不良牛牧場> [1;33mzoo.ee.ntu.edu.tw [1;32m(140.112.18.36) [m
[1;32mWelcome to SimFarm BBS [1;36m-- [m [1;31mFrom : [ [m211.72.86.17 [1;31m] [m

烏拉諾斯

unread,
Aug 17, 2001, 7:11:25 AM8/17/01
to
※ 引述《WaSiVaG...@zoo.ee.ntu.edu.tw (等你說喜歡我)》之銘言:
> ※ 引述《Apya...@bbs.yuntech.edu.tw (烏拉諾斯)》之銘言:

> : The private member variable is just accessed by the public member function.
> : So..It is not BCB's bug.
> 你好像沒仔細看我的問題內容 const int*ptrm=&A::m;
> 這樣不是已經讓ptrm得到A:m的address 再dereference
> 就得到它的值 這樣不算access嗎???
The following error
1.A is a class type,but not a object.
you don't declare a object of class A.
In reality,neither a object of class A is allocated memory in the program.
2.the :: is a scope operator
In the class It's just used by function which i know.
the private variable is accessed by public function.
3.U can't specify any value in the undeclared object because the m's memory
is unallocated by any object.
4.U don't specify the type of m.
0 new messages