0

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..

Andre Kampling
  • 5,476
  • 2
  • 20
  • 47
Gyts18
  • 1
  • 1
    Welcome to Stack Overflow. Please take the time to read [The Tour](http://stackoverflow.com/tour) and refer to the material from the [Help Center](http://stackoverflow.com/help/asking) what and how you can ask here. – πάντα ῥεῖ May 23 '17 at 22:30
  • found one error where node i fixed it and changed to what i need (studentas, not node) – Gyts18 May 23 '17 at 22:31
  • https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list – πάντα ῥεῖ May 23 '17 at 22:32
  • Only class members and `friend`s can see private members, and members must be invoked on an instance of the class. – user4581301 May 23 '17 at 22:37

0 Answers0