C
Chris
This is the code:
######################
#include <stdlib.h>
using namespace std;
class intlist {
unsigned int length;
int * list;
public:
intlist() {
length = 0;
list = (int *) malloc(length * sizeof(int)); }
~intlist() {
free(list); }
void append(int value) {
length += 1;
list = realloc(list, length * sizeof(int));
list[length-1] = value; } };
int main() {
intlist a;
return 0; }
######################
This is the Error:
In member function `void intlist::append(int)':
invalid conversion from `void*' to `int*'
Can anyone tell me why i am getting this error? I compiled it with
Bloodshed Dev-C++.
Thanks for any help!
-Chris
######################
#include <stdlib.h>
using namespace std;
class intlist {
unsigned int length;
int * list;
public:
intlist() {
length = 0;
list = (int *) malloc(length * sizeof(int)); }
~intlist() {
free(list); }
void append(int value) {
length += 1;
list = realloc(list, length * sizeof(int));
list[length-1] = value; } };
int main() {
intlist a;
return 0; }
######################
This is the Error:
In member function `void intlist::append(int)':
invalid conversion from `void*' to `int*'
Can anyone tell me why i am getting this error? I compiled it with
Bloodshed Dev-C++.
Thanks for any help!
-Chris