Good day. I was wondering if I could get some help on this. I've got the following:
#include <vector>
#include <complex>
#include <iostream>
using messageScalar = std::complex<double>;
using messageVector = std::vector<messageScalar>;
using messageMatrix = std::vector<messageVector>;
class Tester {
 public:
  Tester(messageVector t) {
      messageMatrix container(1, t);
      messages = &container;
  }
  Tester(messageMatrix t) {
      messages = &t;
  }
  void debug() {
      std::cout << (*messages).size() << std::endl;
      for (auto &vector: *messages) {  // <- Debugger # 1
          for (auto &scalar: vector) {  // <- Debugger # 2
              std::cout << scalar << std::endl;
          }
      }
  }
 private:
  messageMatrix *messages = nullptr;
};
int main() {
    messageMatrix cMatrix = {{1, 2, 3}, {3, 4, 5}};
    Tester first(cMatrix);
    first.debug();
}
At the very end, I'm getting a segfault on this. It's telling me that I have 2 entries (which I expect - the number of "rows") but it's not clear to me why the segfault is happening.
2
18446744072976776191
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
When using the debugger at #1, I get back a variable of "this" where I try to open it and get back
Cannot access memory at address X
and when I move the debugger to the next line it apparently has more entries than I've put in (3) for that row.
Am I missing something obvious? I've also tried doing an
Tester(messageVector t) {
      messageMatrix container;
      container.emplace_back(t);
      messages = &container;
  }
but that didn't work either (not that it should but I'm going out of my mind)
 
    