flu*_*els 0 c++ compiler-construction syntax segmentation-fault
最近,在我累了之后,我写了下面的代码:
GLfloat* array = new GLfloat(x * y * z);
Run Code Online (Sandbox Code Playgroud)
当然应该是:
GLfloat* array = new GLfloat[x * y * z];
Run Code Online (Sandbox Code Playgroud)
(注意方括号而不是括号.)
据我所知,第一种形式无效,但g ++编译了它.当然,它吐出了一个完全不可理解的段错误,但它汇编了.
为什么?
dir*_*tly 15
GLfloat* array = new GLfloat(x * y * z);
Run Code Online (Sandbox Code Playgroud)
创建一个名为array对象的对象,GLfloat其值为x * y * z.
| 归档时间: |
|
| 查看次数: |
439 次 |
| 最近记录: |