Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe some possible questions in your Cpp-Primer/ch02 #15

Closed
ghost opened this issue Feb 6, 2015 · 7 comments
Closed

Maybe some possible questions in your Cpp-Primer/ch02 #15

ghost opened this issue Feb 6, 2015 · 7 comments

Comments

@ghost
Copy link

ghost commented Feb 6, 2015

1.exercise 2.5 lose answer of (d)

2.exercise 2.6 your answer is “The first line's integer is decimal, the second line's integer is octal.”, but I think second line’s first integer isn’t octal . 9 doesn’t appear in Octal like that A doesn’t appear in decimal.

3.exercise 2.27 your answer think that “int *const p2 = &i2” is legal,
But if i2 is a variable of double type ,what’s the answer ?so it’s not strict .
So (d),(f) have same questions ,we don’t know i2 what type it is .

  1. exercise 2.31 r1 = v2 is illegal. Error message : invalid initialization of reference of type 'int&' from expression of type 'const int'

My English level is very poor , so can you understand what I want to express?thanks!

pezy added a commit that referenced this issue Feb 6, 2015
@pezy
Copy link
Owner

pezy commented Feb 6, 2015

Hi, @cxs944745612 Good to see you. 😄

1 and 2, you are right, and I have tried to fix it.

3 int *const p2 = &i2, we can judge the variable type according by it's name. Or, the question make no sense. Thus, i2 should be an integer, rather than double as you say.

4 I can't sure whether it will appear this error message. I am try to list the related codes as following:

const int v2 = 0;
int v1 = v2;
int &r1 = v1;
// above is previous exercise (Exercise 2.30)
r1 = v2;

Use Clang 3.5 and gcc 4.9.2, All passed. Could you please tell me what environment do you have?

Thx a lot for bug reporting. 👍

@ghost
Copy link
Author

ghost commented Feb 7, 2015

I'm very sorry ,it's my fault .You're right!
what's more,you say"we can judge the variable type according by it's name",it means that we keep i2 as a default integer variable .( i: integer, d: double, f: float. so d2 is a double variable in c++ primer ? like this?)
My English level is very poor , so can you understand what I want to express? I really want to say Chinese ! thanks a lot for your guidance!

@jjjasperd
Copy link

我觉着你们俩可以用中文讨论来着:)

@pezy
Copy link
Owner

pezy commented Feb 7, 2015

@cxs944745612 @jjjasperd

那咱们以后就用中文吧~ 🇨🇳

i: integer, d: double, f: float. so d2 is a double variable in c++ primer ? like this?

是的,就是这样,这本书的命名很讲究,也为初学者培养好不乱命名的好习惯。除了你提到的,第二章里,还有 r 代表 reference, c 代表 const, p 代表 pointer.

@pezy pezy closed this as completed Feb 7, 2015
@ghost
Copy link
Author

ghost commented Feb 7, 2015

好的,非常感谢!我有些新的问题请教您,我又提了两个问题在知乎上邀请您回答了,如果有时间的话,麻烦您了。

@pezy
Copy link
Owner

pezy commented Feb 8, 2015

@cxs944745612 真的抱歉,周末有些事耽搁了,明天我帮你看看~ 🏇

@ghost
Copy link
Author

ghost commented Feb 11, 2015

没事没事,您有时间就看,非常感谢您的无私帮助!

sarvex pushed a commit to sarvex/CppPrimer that referenced this issue Apr 27, 2023
add error information--quite nice!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants