t*s
2 楼
1。 Sunrise Over Potomac River
2010年最后一个早上拍的。祝大家新年万事如意!
2。 DC Sunset Rider
然后献上圣诞那天拍的,祝大家事业如日中天,摄影水平一骑绝尘,没有traffic。:)
2010年最后一个早上拍的。祝大家新年万事如意!
2。 DC Sunset Rider
然后献上圣诞那天拍的,祝大家事业如日中天,摄影水平一骑绝尘,没有traffic。:)
b*d
3 楼
class myc
{
...
public:
...
void donothing() {cout<};
int main()
{
myc *p=0;
p->donothing();
}
output:
I do nothing!
经我测试,default constructor, copy constructor, = assignment operator 都没
有被调用。而且指针为0,换成NULL也一样。但是却可以使用类的函数。
请问:p指向的object(这里其实都没有,因为是0)是怎么产生的?
{
...
public:
...
void donothing() {cout<};
int main()
{
myc *p=0;
p->donothing();
}
output:
I do nothing!
经我测试,default constructor, copy constructor, = assignment operator 都没
有被调用。而且指针为0,换成NULL也一样。但是却可以使用类的函数。
请问:p指向的object(这里其实都没有,因为是0)是怎么产生的?
b*y
4 楼
近期要考REG的同学可以加QQ群 142602456 做广告搞推销的一律免进,进了踢。欢迎大
家一起学习讨论。我11月底考,大家互帮互助!
家一起学习讨论。我11月底考,大家互帮互助!
m*a
5 楼
你不如问问组里的人
各个地方情况不一样
有些组给的条件就是很FIRM的
各个地方情况不一样
有些组给的条件就是很FIRM的
m*1
6 楼
Very nice!!!
l*s
7 楼
under the hood, member function is really a normal function with a hidden
parameter bound to "this".
you passed in an invalid pointer, but it does not cause problem because you
don't use instance data. o.w, you will trigger runtime error.
parameter bound to "this".
you passed in an invalid pointer, but it does not cause problem because you
don't use instance data. o.w, you will trigger runtime error.
b*y
8 楼
自己更新一下,希望更多同学看见。
r*5
10 楼
赞。那个大冷天,我在被窝睡懒觉,你在外面吹冷风。发觉自己越来越懒了。
g*e
11 楼
只有access member variable的时候才用到p指针
v*0
12 楼
lz
, qq number is not valid.
, qq number is not valid.
g*e
13 楼
只有access member variable的时候才用到p指针
b*y
14 楼
没错。是群,要加群。
b*d
15 楼
谢谢!
我的问题是p指针变量的值应该是个地址。一般情况是个object的地址。但这里是0. 那
p是怎么找到member function的地址的?是系统产生了一个不完全的object交给p?还
是p可以直接在member function列表里找需要的函数,虽然p=0?
you
【在 l*********s 的大作中提到】
: under the hood, member function is really a normal function with a hidden
: parameter bound to "this".
: you passed in an invalid pointer, but it does not cause problem because you
: don't use instance data. o.w, you will trigger runtime error.
我的问题是p指针变量的值应该是个地址。一般情况是个object的地址。但这里是0. 那
p是怎么找到member function的地址的?是系统产生了一个不完全的object交给p?还
是p可以直接在member function列表里找需要的函数,虽然p=0?
you
【在 l*********s 的大作中提到】
: under the hood, member function is really a normal function with a hidden
: parameter bound to "this".
: you passed in an invalid pointer, but it does not cause problem because you
: don't use instance data. o.w, you will trigger runtime error.
l*s
16 楼
2nd explanation is partially correct as object creation is not involved at
all. but there is no such process of member function lookup. Non-virtual
function address is determined at compiling time.
【在 b*****d 的大作中提到】
: 谢谢!
: 我的问题是p指针变量的值应该是个地址。一般情况是个object的地址。但这里是0. 那
: p是怎么找到member function的地址的?是系统产生了一个不完全的object交给p?还
: 是p可以直接在member function列表里找需要的函数,虽然p=0?
:
: you
all. but there is no such process of member function lookup. Non-virtual
function address is determined at compiling time.
【在 b*****d 的大作中提到】
: 谢谢!
: 我的问题是p指针变量的值应该是个地址。一般情况是个object的地址。但这里是0. 那
: p是怎么找到member function的地址的?是系统产生了一个不完全的object交给p?还
: 是p可以直接在member function列表里找需要的函数,虽然p=0?
:
: you
x*q
17 楼
可以这么理解,编译器是指上把这个方程编译成了类似
blahblah7myc8donothing9Ev(myc*)的C方程。
C++是静态语言,编译时就已经通过p的namespace,declared type/class和function
name找到了上述方
程,然后把p做参数压栈,call blahblah7myc8donothing9Ev而已。
所以,并非通过p找到了member function,而是通过p的类型找到的该方程。非virtual
function,每个类的object并不保存member function的地址。
【在 b*****d 的大作中提到】
: 谢谢!
: 我的问题是p指针变量的值应该是个地址。一般情况是个object的地址。但这里是0. 那
: p是怎么找到member function的地址的?是系统产生了一个不完全的object交给p?还
: 是p可以直接在member function列表里找需要的函数,虽然p=0?
:
: you
blahblah7myc8donothing9Ev(myc*)的C方程。
C++是静态语言,编译时就已经通过p的namespace,declared type/class和function
name找到了上述方
程,然后把p做参数压栈,call blahblah7myc8donothing9Ev而已。
所以,并非通过p找到了member function,而是通过p的类型找到的该方程。非virtual
function,每个类的object并不保存member function的地址。
【在 b*****d 的大作中提到】
: 谢谢!
: 我的问题是p指针变量的值应该是个地址。一般情况是个object的地址。但这里是0. 那
: p是怎么找到member function的地址的?是系统产生了一个不完全的object交给p?还
: 是p可以直接在member function列表里找需要的函数,虽然p=0?
:
: you
t*t
18 楼
I would say this compiler sucks. it should catch such error instead of
letting it pass.
letting it pass.
t*t
20 楼
for this case, no runtime check is needed.
compiler should give warning whenever an integer is used as address and
assigned to a pointer. which means, pointer can only be get from new or from
another pointer. IMO, developer should never do it.
so such code will always get warning and alert the developer.
or, can set the compiler stricter, give error instead of warning.
i don't see the need to assign integer to pointer unless for very low level
programming.
are
【在 t****t 的大作中提到】
: catching such error requires runtime check. most of these kind of error, are
: "no diagnostic required" by standard.
compiler should give warning whenever an integer is used as address and
assigned to a pointer. which means, pointer can only be get from new or from
another pointer. IMO, developer should never do it.
so such code will always get warning and alert the developer.
or, can set the compiler stricter, give error instead of warning.
i don't see the need to assign integer to pointer unless for very low level
programming.
are
【在 t****t 的大作中提到】
: catching such error requires runtime check. most of these kind of error, are
: "no diagnostic required" by standard.
t*t
21 楼
you do know null pointer is traditionally expressed by number 0, don't you?
in fact, literal integer 0 is the only way to express null pointer. NULL is
simply a macro form of literal integer 0. you want a warning everytime null
pointer is used?
of course, in c++11, there is this new nullptr keyword.
from
level
【在 t***t 的大作中提到】
: for this case, no runtime check is needed.
: compiler should give warning whenever an integer is used as address and
: assigned to a pointer. which means, pointer can only be get from new or from
: another pointer. IMO, developer should never do it.
: so such code will always get warning and alert the developer.
: or, can set the compiler stricter, give error instead of warning.
: i don't see the need to assign integer to pointer unless for very low level
: programming.
:
: are
in fact, literal integer 0 is the only way to express null pointer. NULL is
simply a macro form of literal integer 0. you want a warning everytime null
pointer is used?
of course, in c++11, there is this new nullptr keyword.
from
level
【在 t***t 的大作中提到】
: for this case, no runtime check is needed.
: compiler should give warning whenever an integer is used as address and
: assigned to a pointer. which means, pointer can only be get from new or from
: another pointer. IMO, developer should never do it.
: so such code will always get warning and alert the developer.
: or, can set the compiler stricter, give error instead of warning.
: i don't see the need to assign integer to pointer unless for very low level
: programming.
:
: are
t*t
22 楼
this can be enforced by compiler.
if assign integer 0, give warning.
if assign by macro null, pass.
and actually this can only be done by compiler, not run time, because
pointer is integer at runtime. only compiler knows that it's integer or
pointer.
?
is
null
【在 t****t 的大作中提到】
: you do know null pointer is traditionally expressed by number 0, don't you?
: in fact, literal integer 0 is the only way to express null pointer. NULL is
: simply a macro form of literal integer 0. you want a warning everytime null
: pointer is used?
: of course, in c++11, there is this new nullptr keyword.
:
: from
: level
if assign integer 0, give warning.
if assign by macro null, pass.
and actually this can only be done by compiler, not run time, because
pointer is integer at runtime. only compiler knows that it's integer or
pointer.
?
is
null
【在 t****t 的大作中提到】
: you do know null pointer is traditionally expressed by number 0, don't you?
: in fact, literal integer 0 is the only way to express null pointer. NULL is
: simply a macro form of literal integer 0. you want a warning everytime null
: pointer is used?
: of course, in c++11, there is this new nullptr keyword.
:
: from
: level
t*t
23 楼
basically you want to mix PP stage with compile stage.
i think this is generally a very bad idea, unless absolutely necessary. NULL
(not null) or 0 is simply the same token, i think there is more important t
hings to warn about, e.g. multi-value-change-between-sequence-point type of
error; this is implementable and worth the trouble.
distinguishing null or 0 is not worth it. besides there is this new nullptr
keyword now.
【在 t***t 的大作中提到】
: this can be enforced by compiler.
: if assign integer 0, give warning.
: if assign by macro null, pass.
: and actually this can only be done by compiler, not run time, because
: pointer is integer at runtime. only compiler knows that it's integer or
: pointer.
:
: ?
: is
: null
i think this is generally a very bad idea, unless absolutely necessary. NULL
(not null) or 0 is simply the same token, i think there is more important t
hings to warn about, e.g. multi-value-change-between-sequence-point type of
error; this is implementable and worth the trouble.
distinguishing null or 0 is not worth it. besides there is this new nullptr
keyword now.
【在 t***t 的大作中提到】
: this can be enforced by compiler.
: if assign integer 0, give warning.
: if assign by macro null, pass.
: and actually this can only be done by compiler, not run time, because
: pointer is integer at runtime. only compiler knows that it's integer or
: pointer.
:
: ?
: is
: null
f*n
25 楼
Technically according to the standard, it's undefined behavior. Undefined
behavior means it can do anything, crash or not, or blow up your computer.
Whatever.
In practice, non-virtual function calls are looked up at compile time in all
compilers. The pointer is not used in determining which function to call.
【在 b*****d 的大作中提到】
: class myc
: {
: ...
: public:
: ...
: void donothing() {cout<: };
: int main()
: {
: myc *p=0;
behavior means it can do anything, crash or not, or blow up your computer.
Whatever.
In practice, non-virtual function calls are looked up at compile time in all
compilers. The pointer is not used in determining which function to call.
【在 b*****d 的大作中提到】
: class myc
: {
: ...
: public:
: ...
: void donothing() {cout<: };
: int main()
: {
: myc *p=0;
d*n
27 楼
前段时间看见CLANG的邮件列表里有人讨论,也许不用多久,会加入到clang的
undefined behavior sanitizer里了。
【在 t****t 的大作中提到】
: basically you want to mix PP stage with compile stage.
: i think this is generally a very bad idea, unless absolutely necessary. NULL
: (not null) or 0 is simply the same token, i think there is more important t
: hings to warn about, e.g. multi-value-change-between-sequence-point type of
: error; this is implementable and worth the trouble.
: distinguishing null or 0 is not worth it. besides there is this new nullptr
: keyword now.
相关阅读
求购BECKER的2011版FAR教材德州的第一年会计senior manager工资多少啊 (转载)Rober Half 猎头自己打印教材大概得多少钱?用2011年的Becker来准备考2012的CPA,可以吗请帮参考,四所学校的Accounting Master Program,选哪个?如何分类uncategorized expenses into associated companies?Registered CPA in Illinois请问有cpa license在2个或以上州的童鞋大家怎么复习aud的?年纪较大的转行学会计的还有可能进四大吗?associate of applied accounting【出售】2012 Becker 全套,支持paypal付款请问哪有免费的quickbooks下载?只是练习用。Amazon上的书都是正版的吗?申请CPA执照的问题求购wiley 2011 REG and BEC的书跪求 CA ETHICS (2010)考题和答案求refer 已过CPA 现在local CPAfirm 实习中 需要H1b求购5刀pdf一科的becker资料