In one .cpp file, I declare and implement a class "Vertex". Then I declare and implement second class "ThreeDimensionObject". Inside ThreeDimensionObject , it has one public member std::vector> vertex_matrix;
I did import . The project runs fine on xCode IDE and g++ prompt me "error: ‘vertex_matrix’ was not declared in this scope".
How can I fix it?
#include <vector> class Vertex : public std::vector<float> { //implementation }; class ThreeDimensionObject { //the center position public: //num_stack * num_stack * 4 std::vector<std::vector<Vertex>> vertex_matrix; };
std::vectoris an incredibly awful way to represent a vertex in 3-space, as it uses a dynamically allocated block of memory for what should just be 3 or 4 floats (and that block takes up about as much additional overhead as those 4 floats themselves, not to forget thestd::vector's automatic storage itself, that is also as large as the actual vertex data itself). If you really want a standard library container for vertices, then at least settle for astd::array.