Category : heap

My MainWindow constructor: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); Http *http = new Http(locationURL); // crashes qDebug() << *http->getLongitude(); } I have another class Http with .cpp file containing a constructor and 3 methods: QString* Http::getLongitude() { // crashes qDebug() << *longitude; return longitude; } Http::Http(QString url) { // get response QNetworkAccessManager ..

Read more

I am getting this error "libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: vector" for my heapifyDown() I believe. This is the cpp for my priorityqueue. I call heapifyDown() in my removeMin() so I made some changes there but my heapifyDown() seems fine to me. Can anyone help me troubleshoot this? #include <iostream> #include "json.hpp" ..

Read more

Say we have functions: void f1(std::array<int, 3> arr) { /* … */} void f2(const std::array<int, 3>& arr) { /* … */} My questions are about whether arr is on the heap or on the stack. I guess it depends how those functions are called. Are these affirmations correct? int main() { std::array<int, 3> arr{1, 2, ..

Read more