新foo [42] [英] new foo[42]

查看:56
本文介绍了新foo [42]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我上次看到很多像:


float * foo = new float [42];


第一个问题:这不对,不是吗?

必须是:


float ** foo = new float [42]; ?????


第二个问题

有什么区别


float foo [42]; ??

Simon Adler


-

BOFH借口#69:

电缆结导致数据流变得扭曲和扭曲

Hello,

in the last time I see a lot like:

float * foo = new float[42];

First question: This isn''t right, isn''t it?
It has to be:

float ** foo = new float[42]; ?????

Second Question
What is the difference to

float foo[42]; ??
Simon Adler

--
BOFH excuse #69:
knot in cables caused data stream to become twisted and kinked

推荐答案



" Simon Adler" < SI *** @ wohnheim.fh-wedel.de>在消息中写道

"Simon Adler" <si***@wohnheim.fh-wedel.de> wrote in message
你好,

在上次我看到很多时候:

float * foo = new float [42];

第一个问题:这不对,不是吗?


这是正确的。

它必须是:

float ** foo = new float [42]; ?????


这不是。谁告诉你这是正确的?如有疑问请尝试编译。

第二个问题

浮动foo [42]; ??
Hello,

in the last time I see a lot like:

float * foo = new float[42];

First question: This isn''t right, isn''t it?
It is correct.
It has to be:

float ** foo = new float[42]; ?????
This isn''t. Who told you this to be correct ? Try a compiler when in doubt.

Second Question
What is the difference to

float foo[42]; ??




前者动态分配内存(即在运行时)


Sharad



The former allocates memory dynamically (i.e. at run time)

Sharad


Sharad Kala写道:
Sharad Kala wrote:
" Simon Adler" < SI *** @ wohnheim.fh-wedel.de>写了留言
"Simon Adler" <si***@wohnheim.fh-wedel.de> wrote in message
你好,

上次我看到很多像:

float * foo = new float [ 42];

第一个问题:这不对,不是吗?
Hello,

in the last time I see a lot like:

float * foo = new float[42];

First question: This isn''t right, isn''t it?



这是正确的。

它必须是:

float ** foo = new float [42]; ?????
It has to be:

float ** foo = new float[42]; ?????



这不是。谁告诉你这是正确的?如果有疑问,请尝试编译。


This isn''t. Who told you this to be correct ? Try a compiler when in doubt.

第二个问题

浮动foo [42]; ??
Second Question
What is the difference to

float foo[42]; ??



前者动态分配内存(即在运行时)


The former allocates memory dynamically (i.e. at run time)




对象的所有内存都在运行时分配时间。


程序员通常不会认识到的主要区别是''foo''具有

类型'42'浮点数''前一种情况和指向浮动的指标在后一种情况下是
。其他差异是_where_内存被分配

(实现定义)以及对象保留多长时间(标准指定

)。

V



All memory for objects is allocated at run-time.

The major difference not often recognised by programmers is that ''foo'' has
the type ''array of 42 float'' in the former case and ''pointer to float'' in
the latter case. Other differences are _where_ the memory is allocated
(implementation-defined) and how long the object remains around (specified
by the Standard).

V


Simon Adler写道:

[新手问题]


获取你自己_Accelerated C ++ _ by Koenig和Moo。

得到yoruself _The Strictrup的C ++语言。


仔细阅读这两本书。确保

尝试使用您的编译器的所有示例。

查看该组以查找常见问题解答并阅读它。

袜子

Simon Adler wrote:
[newbie questions]

Get yourself _Accelerated C++_ by Koenig and Moo.
Get yoruself _The C++ Language_ by Stroustrup.

Read these two books carefully and closely. Make sure
to try all the examples with your compiler.
Look through this group to find refs to the FAQ and read it.
Socks


这篇关于新foo [42]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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