评估的顺序是++*ptr++什么?当指针和左值涉及到操作时,它会改变吗?
如果的优先级a++高于*a或++a,则将Why ++*a++评估为:首先返回递增的值,然后更改指针,而不是更改指针,然后在该位置递增值。优先权:https://en.cppreference.com/w/cpp/language/operator_precedence
arr = {9, 99, 999 };
int *ptr = arr;
std::cout << ++*ptr++ << '\t';
std::cout << *ptr;
Run Code Online (Sandbox Code Playgroud)
我期望输出为100 100,但实际输出为10 99。
我刚刚开始学习 C++ 中的 Grpahics,以及着色器和精灵。我写了一个小的顶点着色器和一个片段着色器。
顶点着色器:
#version 130
in vec2 vertexPosition;
void main() {
gl_Position.xy = vertexPosition;
gl_Position.z = 0.0;
gl_Position.w = 1.0;
}
Run Code Online (Sandbox Code Playgroud)
片段着色器:
#version 130
out vec3 color;
void main() {
color = vec3(0.94, 0.37, 0.36);
}
Run Code Online (Sandbox Code Playgroud)
编译时,我收到以下错误消息:
Fragment shader failed to compile with the following errors:
ERROR: 0:6: error(#143) Undeclared identifier: gl_Position
ERROR: 0:6: error(#216) Vector field selection out of range "xy"
ERROR: 0:6: error(#160) Cannot convert from: "default in highp 2-component vector of vec2" to: "float"
ERROR: …Run Code Online (Sandbox Code Playgroud)