T
Tomas
Hi NG.
I have a problem with strings.
I have defined this class:
class wort_cl
{
int haeufigkeit;
int length;
string wort;
public:
wort_cl();
wort_cl(string wort_neu, int haeufigkeit_neu);
void init(string wort_neu, int haeufigkeit_neu);
int getHaeufig();
int getLength();
string getWort();
void flush();
};
Now I want to implement a list with these elements:
struct list_element_t
{
wort_cl *daswort;
struct list_element_t *next;
};
The list elements are dynamically created using malloc();
void insertList(list_handle_t *h, void *d,int length) {
struct list_element_t *l;
l = (struct list_element_t *)malloc(sizeof(struct list_element_t));
...
*d is a pointer to a wort_cl object. Now I can't figure out how to
initialise the element l->daswort so that it contains the same value
as d.
When I try something like
*(l->daswort)=*((wort_cl*)d);
I get an access violantion.
maybe someone understands my problem and can help me
thomas
I have a problem with strings.
I have defined this class:
class wort_cl
{
int haeufigkeit;
int length;
string wort;
public:
wort_cl();
wort_cl(string wort_neu, int haeufigkeit_neu);
void init(string wort_neu, int haeufigkeit_neu);
int getHaeufig();
int getLength();
string getWort();
void flush();
};
Now I want to implement a list with these elements:
struct list_element_t
{
wort_cl *daswort;
struct list_element_t *next;
};
The list elements are dynamically created using malloc();
void insertList(list_handle_t *h, void *d,int length) {
struct list_element_t *l;
l = (struct list_element_t *)malloc(sizeof(struct list_element_t));
...
*d is a pointer to a wort_cl object. Now I can't figure out how to
initialise the element l->daswort so that it contains the same value
as d.
When I try something like
*(l->daswort)=*((wort_cl*)d);
I get an access violantion.
maybe someone understands my problem and can help me
thomas