I have this implementation of a class that handles linked lists.
The issue is that I'm using primitive functions in the struct I use within the class, however I do not know much about it, and I do not know how to invoke the functions. Here I reproduce my problem. thank you very much
#include <iostream>
#include <stdlib.h>
using namespace std;
class linkedList
{
private:
struct node
{
char valor;
node *next;
node( char nuevoValor, node * nuevoNext)
: valor( nuevoValor ), next( nuevoNext )
{ }
// prinmitivos
static node * stringALista(const char *s); // para el constructor
};
node *head;
public:
explicit linkedList( const char * s = "");
//linkedList( const linkedList & s );
};
int main()
{
linkedList list1 ("hola mundo");
}
linkedList::linkedList(const char *s)
{
// como llamar a la funcion stringALista???
}
// aquí ↓ dice 45 11 Error] expected unqualified-id before '.' token
linkedList.node * linkedList::stringALista(const char *s)
{
node * aux = NULL;
node * cur = NULL;
int i = 0;
while ( ( s + i * sizeof(char)) != '#include <iostream>
#include <stdlib.h>
using namespace std;
class linkedList
{
private:
struct node
{
char valor;
node *next;
node( char nuevoValor, node * nuevoNext)
: valor( nuevoValor ), next( nuevoNext )
{ }
// prinmitivos
static node * stringALista(const char *s); // para el constructor
};
node *head;
public:
explicit linkedList( const char * s = "");
//linkedList( const linkedList & s );
};
int main()
{
linkedList list1 ("hola mundo");
}
linkedList::linkedList(const char *s)
{
// como llamar a la funcion stringALista???
}
// aquí ↓ dice 45 11 Error] expected unqualified-id before '.' token
linkedList.node * linkedList::stringALista(const char *s)
{
node * aux = NULL;
node * cur = NULL;
int i = 0;
while ( ( s + i * sizeof(char)) != '%pre%' )
{
if ( cur == NULL)
{
cur = new node;
cur->valor = &s;
cur->next = NULL
aux = cur;
}
else
{
while (cur->next != NULL)
cur = cur->next;
cur->next = new node;
cur->next->valor = &s;
cur->next->next = NULL;
}
}
return aux;
}
' )
{
if ( cur == NULL)
{
cur = new node;
cur->valor = &s;
cur->next = NULL
aux = cur;
}
else
{
while (cur->next != NULL)
cur = cur->next;
cur->next = new node;
cur->next->valor = &s;
cur->next->next = NULL;
}
}
return aux;
}
What I want is to be able to use the function of the structure in the linkedList class.