L
lestat
I have switched to a new compiler (gcc/g++ 3.2 on rh linux 8.0) and I
cannot seem to dynamically allocate two dimentonal arrays (or even
singel dimetional arrays!) of any user defined classes.
Here is a simple example of an array of user defined class that *used*
to work, but doesn't anymore:
-------------------begin code-----------------------
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
class Pixel
{
public:
Pixel();
int i;
int j;
};
int main()
{
Pixel p[4];
for (int i=0;i<4;i++)
{
p.i=i;
p.j=i*i;
}
for (int i=0;i<4;i++)
{
cout<<p.i<< " "<<p.j<<endl;
}
return 0;
}
----------------------end code------------------
Here is the error message I get when I compile:
[root@voyager hw5]# g++ -o dblarray dblarray.cpp
/tmp/ccMX0JlL.o: In function `main':
/tmp/ccMX0JlL.o(.text+0x30): undefined reference to
`Pixel:ixel[in-charge]()'
collect2: ld returned 1 exit status
[root@voyager hw5]#
I get the same error if I try to allocate pointers of pointers etc...
Any idea what I'm missing?
--Dave
cannot seem to dynamically allocate two dimentonal arrays (or even
singel dimetional arrays!) of any user defined classes.
Here is a simple example of an array of user defined class that *used*
to work, but doesn't anymore:
-------------------begin code-----------------------
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
class Pixel
{
public:
Pixel();
int i;
int j;
};
int main()
{
Pixel p[4];
for (int i=0;i<4;i++)
{
p.i=i;
p.j=i*i;
}
for (int i=0;i<4;i++)
{
cout<<p.i<< " "<<p.j<<endl;
}
return 0;
}
----------------------end code------------------
Here is the error message I get when I compile:
[root@voyager hw5]# g++ -o dblarray dblarray.cpp
/tmp/ccMX0JlL.o: In function `main':
/tmp/ccMX0JlL.o(.text+0x30): undefined reference to
`Pixel:ixel[in-charge]()'
collect2: ld returned 1 exit status
[root@voyager hw5]#
I get the same error if I try to allocate pointers of pointers etc...
Any idea what I'm missing?
--Dave