Моя проблема заключается в следующем. У меня есть векторный класс elementList, который содержит элементы, описывающие треугольники вдоль поверхности, но когда я добавляю индивидуально созданные элементы в elementList через emplace_back, их адрес меняется.
Если вам нужен дополнительный код, дайте мне знать , но я убрал лишнее, чтобы получить то, что, как мне кажется, является самым необходимым. Первый элементСписок:
Код: Выделить всё
class elementList
{
public:
elementList(std::string filename);
std::vector const& get_elements() const;
private:
std::vector m_elements;
};
Код: Выделить всё
class element
{
public:
element(float x11, float x12, float x21, float x22, float x31, float x32);
std::vector const& nodes() const;
std::vector const& edges() const;
[...]
private:
std::vector m_nodes;
std::vector m_edges;
[...]
};
Код: Выделить всё
elementList::elementList(std::string filename)
{
[...] //parse node coordinates from source file
m_elements.emplace_back(element(x11,x12,x21,x22,x31,x32)); //1
}
Код: Выделить всё
element::element(float x11, float x12, float x21, float x22, float x31, float x32)
{
[...]
std::cout
Источник: [url]https://stackoverflow.com/questions/78141638/stop-overwriting-addresses-in-vector[/url]