i am new to using c++
When I execute the following code
i am aware it shouldn’t draw anything at the moment i am just trying to change from using an array for vertex position to using a vector as i want to be able to calculate points then use a push_back to append them.
This minimal example won’t compile:
#include <vector>
std::vector<float> vertexPositions;
const float triangle = 0.75f;
vertexPositions.push_back(triangle);
int main(int argc, char** argv)
{
return 0;
}
I get:
error: ‘vertexPositions’ does not name a type
vertexPositions.push_back(triangle);is a statement. It must be placed inside a function definition. It can not be placed in the global scope like that.Move that line into for example
main, and you should be fine.