QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 556|回复: 5

Some questions about "li

[复制链接]
发表于 2003-4-19 09:06:05 | 显示全部楼层 |阅读模式
Could someone tell me if my answer are right.

[code:1]struct NodeType;
typedef NodeType* NodePtr;

struct NodeType
{
        int number;
        char character;
        NodePtr link;
};

NodePtr currPtr = NULL;
NodePtr firstPtr = NULL;
NodePtr lastPtr = NULL;

currPtr = new NodeType;
currPtr->number = 13;
currPtr->character = 'z';
currPtr->link = new NodeType;
lastPtr = currPtr->link;
lastPtr->number = 9;
firstPtr = new NodeType;
lastPtr->link = firstPtr;
firstPtr->number = 9;
firstPtr->character = 'h';
firstPtr->link = currPtr;
[/code:1]

a. firstPtr->link->number
b. firstPtr->link->link->character
c. firstPtr->link == lastPtr
d. currPtr->link->number
e. currPtr->link == *lastPtr
f. firstPtr == lastPtr->Link
g. firstPtr->number < firstPtr->link->number

my answers:

a. 13
b. undefined
c. False
d. 9
e. False
f. True
g. True
发表于 2003-4-19 10:34:01 | 显示全部楼层
other should be right.
but b is not undefined. it is an uninitialized char, so should be zero or any value.
回复

使用道具 举报

 楼主| 发表于 2003-4-19 11:08:10 | 显示全部楼层
howcome?
回复

使用道具 举报

发表于 2003-4-19 11:12:46 | 显示全部楼层
[quote:ba78900564="CNOOC"]howcome?[/quote]

what u mean?
回复

使用道具 举报

 楼主| 发表于 2003-4-19 11:17:01 | 显示全部楼层
I mean why it should be zero or any numbers?
回复

使用道具 举报

发表于 2003-4-19 11:22:34 | 显示全部楼层
u do not init the lastptr. so its value is uninitialized. for old c++ spec. a new object will init to a zero value. but latest spec will leave it uninitialized. so u had better init it before u use it.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-16 04:48 , Processed in 0.035389 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表