Titti92
11-12-2013, 09:26
#include <iostream>
using namespace std;
template<typename T>
class lista{
private:
struct list{
T n;
struct list* p;
}*punt,*next;
public:
lista(){
punt=new lista;
next=new lista;
next=punt;
punt->n=0;
punt->p=NULL;
}
void insert(T k){
next->n=k;
next->p=new lista;
next=next->p;
next->p=NULL;
}
};
int main(){
lista<int> c();
c.insert(2);
return 0;
}
Lasciate perdere l'errato uso dei puntatori all'interno delle funzioni, ho un problema quando nel main vado a richiamare la funzione c.insert(2). L'errore che mi da il compilatore è:
[Error] request for member 'insert' in 'c', which is of non-class type 'lista<int>*()'
cosa ho sbagliato?
using namespace std;
template<typename T>
class lista{
private:
struct list{
T n;
struct list* p;
}*punt,*next;
public:
lista(){
punt=new lista;
next=new lista;
next=punt;
punt->n=0;
punt->p=NULL;
}
void insert(T k){
next->n=k;
next->p=new lista;
next=next->p;
next->p=NULL;
}
};
int main(){
lista<int> c();
c.insert(2);
return 0;
}
Lasciate perdere l'errato uso dei puntatori all'interno delle funzioni, ho un problema quando nel main vado a richiamare la funzione c.insert(2). L'errore che mi da il compilatore è:
[Error] request for member 'insert' in 'c', which is of non-class type 'lista<int>*()'
cosa ho sbagliato?