gdb or wrong syntax?

So I'm debugging this program with GNU's debugger and it has this nice display command that you can use to display the value of any variable you want as you're tracing through your progam anyway I tried calling

display this->centers.cx

but it's giving me this error message:

(gdb) display this->centers[i].cx
10: this->centers[i].cx = There is no member named cx.
Disabling display 10 to avoid infinite recursion.


However this(the nsMetaballs object I'm referencing) does have a data member centers. Here's the code

nsMetaballs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef _NSMETABALLS
#define _NSMETABALLS

#include <stdlib.h>
#include <stdio.h>

class Metaballs {

typedef struct {
  double cx, cy, cz;
} Center;

public:
  Metaballs():nMetaballs(0), centers(0){};
  Metaballs(const char *);
  ~Metaballs();

  unsigned int getnMetaballs() { return this->nMetaballs; }
  
protected:
  unsigned int nMetaballs;
  Center *centers;
  FILE *fp;
  
};

#endif 


centers is a pointer to an instantiation of Center which has 3 double pointers
cx, cy and cz. So why isn't the debugger giving me the value? Thanks for your help.
Last edited on
if 'this' is a pointer to an object of type Metaballs, then presumably this->centers is the pointer named centers. centers does not appear to be any kind of array.

What is this->centers[i]? What is that i for?
Last edited on
centers is a pointer to a Center "object" there are actually several of them in a row, because I called this code when I constructed my Metaballs object:

1
2
3
4
5
6
7
8
9
      for (unsigned int i = 0; i < this->nMetaballs; i++)
	{
	  float cx, cy, cz;
	  fscanf(fp, "%f %f %f\n", &cx, &cy, &cz);
	  
	  this->centers[i].cx = cx;
	  this->centers[i].cy = cy;
	  this->centers[i].cz = cz;
	}
Topic archived. No new replies allowed.