“Accelerated C ++”初学者问题。 [英] "Accelerated C++" beginner question.

查看:68
本文介绍了“Accelerated C ++”初学者问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好书 - 我喜欢与其他书籍不同的方式,AC ++对所讨论的每一段代码尽可能地解释为

所以我不会离开

想着,好吧......好吧......我得到第12行,但我想知道其余的

是什么意思......


不过,我有一些问题,令我感到沮丧: -

感谢任何评论。


1.

#include< iostream> //(或任何包含文件)在本

书中使用,并且

#include< iostream.h> //用于我看过的其他书籍。


2..h缺席是否与需求有关

for std ::在cout之前?


3. std,这本书是esplains,是一个名字。但什么是命名空间,

特别是在这种情况下?是否可以打开并查看

记事本?


.................. ...................

我到第4章,并且相对适应它,但是这些

早期的问题仍在唠叨我。


谢谢

Great book - I like the way that unlike other books, AC++ explains as
much as possible about every piece of code discussed, so I''m not left
thinking, "well...OK... I get line 12, but I wonder what the rest of
it means...".

Still, I have some questions, that are frustrating me:-
Grateful for any comments.

1. What is the difference between
#include <iostream> // (or any include file) which is used in this
book, and
#include <iostream.h> // which is used in other books I''ve looked at.

2. Does the absence of the ''.h'' have something to do with the need
for std:: before cout ?

3. std, the book esplains, is a namesace. But what is a namespace,
particularly in this case?. Is it something I can open and look at in
Notepad?

.....................................
I''m up to chapter 4, and relativaly comfortable with it, but these
early questions are still nagging me.

Thanks

推荐答案

TonyJeffs skrev:
TonyJeffs skrev:
好书 - 我喜欢与其他书籍不同的方式,AC ++尽可能地解释所讨论的每一段代码,所以我不会留下思考,好吧。 ..OK ......我得到第12行,但我想知道它的其余部分是什么意思......

不过,我还有一些问题,令我感到沮丧: -
感谢任何评论。

1.
#include< iostream>之间的区别是什么? //(或任何包含文件)在本书中使用,并且
#include< iostream.h> //在我看过的其他书籍中使用过。
#include< iostream>建议的方法是在c ++中包含文件

(至少对于标准库)

#include< iostream.h>几乎一样,除了大多数

编译器会给你一个警告,告诉你它已被弃用。

编写你自己的头文件时 - 选择最适合你的。 br />
就个人而言,我喜欢.h或.hpp

2..h缺席是否与std的需求有关
::在cout之前?

No.

3. std,这本书是esplains,是一个名字。但什么是命名空间,
特别是在这种情况下?是否可以打开并在
记事本中查看?
Great book - I like the way that unlike other books, AC++ explains as
much as possible about every piece of code discussed, so I''m not left
thinking, "well...OK... I get line 12, but I wonder what the rest of
it means...".

Still, I have some questions, that are frustrating me:-
Grateful for any comments.

1. What is the difference between
#include <iostream> // (or any include file) which is used in this
book, and
#include <iostream.h> // which is used in other books I''ve looked at. #include <iostream> is the suggested way of including files
in c++ (at least for standard libraries)
#include <iostream.h> is just about the same, except most
compilers will give you a warning telling you its deprecated.
When writing your own header files - select what suits you the best.
Personally, I like .h or .hpp

2. Does the absence of the ''.h'' have something to do with the need
for std:: before cout ?
No.
3. std, the book esplains, is a namesace. But what is a namespace,
particularly in this case?. Is it something I can open and look at in
Notepad?



命名空间是一种将事物分组的概念 - 如函数,类

和常量 - 属于一起。

使用命名空间使代码更易读,更容易

维护。

标准库,如iostream,使用名为

std的命名空间 - 这就是为什么你会看到''std :: cout<< "等等" << std :: endl;''

或''使用命名空间std;''


Google it。


- Pelle


A namespace is a concept of grouping things - like functions, classes
and constants - that belong together.
Using namespaces makes your code more readable and more easily
maintained.
The standard libraries, such as iostream, use a namespace called
std - that''s why you see things like ''std::cout << "blah" << std::endl;''
or ''using namespace std;''

Google it.

-- Pelle




" TonyJeffs" <到******* @ aol.com>在消息中写道

"TonyJeffs" <to*******@aol.com> wrote in message
好书 - 我喜欢与其他书籍不同的方式,AC ++尽可能地解释所讨论的每一段代码,所以我不是离开


我没有读过任何人对这本书说不出口:-)

思考,好吧......好吧......我得到了第12行,但我想知道其余的意思是什么......

不过,我还有一些问题,令我感到沮丧: -
感激任何人评论。

1.
#include< iostream>之间的区别是什么? //(或任何包含文件)在本书中使用,并且
#include< iostream.h> //在我看过的其他书籍中使用过。


你看过的其他书籍已经过时了。标准标题是

无扩展名。


2.缺少.h是否与需要有关
std ::在cout之前?


是的,标准头文件中的所有内容都包含在std命名空间内。所以

cout需要作为std :: cout来解决。

3. std,这本书是esplains,是一个名字。但什么是命名空间,
特别是在这种情况下?是否可以打开并在
记事本中查看?
Great book - I like the way that unlike other books, AC++ explains as
much as possible about every piece of code discussed, so I''m not left
I haven''t read anyone saying otherwise about the book :-)
thinking, "well...OK... I get line 12, but I wonder what the rest of
it means...".

Still, I have some questions, that are frustrating me:-
Grateful for any comments.

1. What is the difference between
#include <iostream> // (or any include file) which is used in this
book, and
#include <iostream.h> // which is used in other books I''ve looked at.
The other books you have looked at are outdated. Standard headers are
extensionless.

2. Does the absence of the ''.h'' have something to do with the need
for std:: before cout ?
Yes, everything inside standard headers is wrapped inside std namespace. So
cout needs to be addressed as std::cout.
3. std, the book esplains, is a namesace. But what is a namespace,
particularly in this case?. Is it something I can open and look at in
Notepad?




与记事本有什么名称空间?命名空间允许我们在名称下对

组的全局类,对象和/或函数进行分组。这有助于避免名称冲突和重新定义错误。


名称空间a {

int i; // OK

}


名称空间b {

int i; //好的

}


Sharad




What have namespaces to do with Notepad ?? Namespaces allow us to group a
set of global classes, objects and/or functions under a name. This helps in
avoiding name conflicts, and redefinition errors.

namespace a {
int i; // OK
}

namespace b {
int i; // OK
}

Sharad





" Pelle Beckman" <他****** @ chello.se>在消息中写道

"Pelle Beckman" <he******@chello.se> wrote in message
1.
#include< iostream>之间的区别是什么? //(或任何包含文件)在本书中使用,并且
#include< iostream.h> //在我看过的其他书籍中使用过。 #include< iostream>是包含文件的建议方式
1. What is the difference between
#include <iostream> // (or any include file) which is used in this
book, and
#include <iostream.h> // which is used in other books I''ve looked at. #include <iostream> is the suggested way of including files




不建议,但在ISO C ++中包含文件的正确方法。
$ c $ b in c ++(至少对于标准库)
#include< iostream.h>几乎一样,除了大多数
编译器会给你一个警告,告诉你它已被弃用。
在编写自己的头文件时 - 选择最适合你的。
我个人喜欢。 h或.hpp



Not suggested, but correct way of including files in ISO C++.
in c++ (at least for standard libraries)
#include <iostream.h> is just about the same, except most
compilers will give you a warning telling you its deprecated.
When writing your own header files - select what suits you the best.
Personally, I like .h or .hpp


2.缺少''。''是否与stout :: cout之前的需要有关?

2. Does the absence of the ''.h'' have something to do with the need
for std:: before cout ?


没有。




为什么?



Why ?

3. std,书中的esplains,是一个名字。但什么是命名空间,
特别是在这种情况下?是否可以在记事本中打开并查看?
3. std, the book esplains, is a namesace. But what is a namespace,
particularly in this case?. Is it something I can open and look at in
Notepad?


命名空间是一种将事物分组的概念 - 如函数,类
和常量 - 属于一起。使用命名空间可以使代码更易读,更容易维护。


A namespace is a concept of grouping things - like functions, classes
and constants - that belong together.
Using namespaces makes your code more readable and more easily
maintained.




这是名称空间的唯一目标吗?


Sharad



Is that the only goal of namespaces ?

Sharad


这篇关于“Accelerated C ++”初学者问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆