im getting an error on 'head','tail','cur' and etc. was not declared in this scope starting from line 43. Here is the code :
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
struct studentas
{
int numeris;
string vardas;
char pazymys;
studentas *next;
};
class list
{
private:
studentas *head, *tail;
public:
list()
{
head=NULL;
tail=NULL;
}
};
char random()
{
static char c = 'A' + rand()%6;
return c;
}
void kurti(int &n, string v[])
{
cout << "kiek noresite studentu?" << endl;
cin >> n;
for (int i=0; i<n; i++)
{
studentas *temp=new studentas;
temp->numeris=rand()%10;
temp->vardas=v[rand()%10];
temp->pazymys=random();
temp->next=NULL;
if (head==NULL)
{
head=temp;
tail=temp;
temp=NULL;
}
else
{
tail->next=temp;
tail=temp;
}
}
}
void rodyti(string v[])
{
studentas *temp=new studentas;
temp=head;
while (temp!=NULL)
{
cout << temp->numeris << endl;
cout << temp->vardas << endl;
cout << temp-> pazymys << endl;
temp=temp->next;
}
}
void ideti(int pos, int n, string v[])
{
studentas *pre=new studentas;
studentas *db=new studentas;
node *temp=new node;
db=head;
for (int i=1;i<pos;i++)
{
pre=db;
db=db->next;
}
temp->numeris=rand()%10;
temp->vardas=v[rand()%10];
temp->pazymys=random();
pre->next=temp;
temp->next=cur;
}
int main()
{
int n;
string v[] = {"Adyss","Benas","Vycka","Koste","Petras","Gytis","Audrius","Juste","Ema","Vaidis"};
kurti(n,v);
rodyti(v);
ideti(pos,n,v);
return 0;
}
I was looking for some post's about using class in functions but tried some of them, still doesn't work..