Posts by Gabriel Henrique • 103 points
5 posts
-
0
votes1
answer40
viewsQ: C++: Elements just below the constructor call of a class
In my teacher’s code, he passed the following class template, with the constructor defined below: template<typename T> class CircularBuffer { std::vector<T> _elements; size_t _first, _n;…
-
1
votes0
answers49
viewsQ: Why is there an error coming at the end of a file that ends with blank spaces in a while loop, using the >>read operator?
I want to perform a reading function of a "material" vector (I created this type with "struct"). The reading will be executed from a file. std::vector<material> material_read(std::string s) {…
-
0
votes0
answers134
viewsQ: How to detect the end of a file reading in a while loop in C++
In my code, there’s the struct: struct material { int idmaterial; double rho; double precokg; }; And the reading function of a data vector of type "material", from a file:…
-
1
votes1
answer172
viewsQ: How to access elements of a vector of a type defined by struct?
In my code, I made the following statement of struct: struct material { int idmaterial; double rho; double precokg; }; I wanted to run this function, which reads data from a file:…
-
8
votes2
answers391
viewsQ: C++ (basic): for, references and syntax
My teacher presented this function to us: void escala(std::vector<double> &v, double fator) { for (auto &vi:v){ vi *= fator; } } It serves to multiply all the elements of a vector by a…