jamesjuett / lobster

Interactive Program Visualization Tools
8 stars 3 forks source link

Visualization of Reference Members #302

Open jamesjuett opened 2 years ago

jamesjuett commented 2 years ago

Repro:

#include "iostream"
using namespace std;

class A {
private:
  int &x;
public:
  A(int x) :x(x) {
    cout << "test" << endl;
  }
};

int main() {
  A a(3);
}

Even after it is initialized, the reference member doesn't appear to be bound to anything:

image

(Note that although binding the member to a local parameter is not a great idea in this case, this example should still visualize something and ideally the reference would also visualize as being invalid after the constructor has finished executing. Visualizing as invalid might well be a separate issue than this, though.)