[ svemirski @ 21.04.2010. 15:55 ] @
Ako imam ove klase:

Code:

class Student  
  {
    char ime_i_prezime[20];
    int indeks;
    char telefon[15];
  public:
    Student(const char*,int,const char*);
    const char *ImePrezime() const {return ime_i_prezime;}
    int Indeks() const {return indeks;       }
    const char *Telefon()    const {return telefon;      }
    void Ispisi()  const;
  };


class Cvor  
  {
  public:
    Student element;
    Cvor *veza;
    Cvor() {};     // ovdje je PROBLEM
    
  };


class Lista 
  {
    Cvor *prvi,*zadnji;  // prvi i zadnji student
  public:
    Lista() {prvi=zadnji=0 ; }
    ~Lista();
    bool PraznaLista() const;
    void DodajNaKraj();
    //  ....
}

void Lista::DodajNaKraj()
{
  Cvor *novi=new Cvor();
  novi->element=UnesiStudenta();
  novi->veza=0;
  // ostatak koda
}



Kada kompajliram u Visual C++ javi mi problem:
Code:
error C2512: 'Student' : no appropriate default constructor available 


[ CiribuCiriba @ 21.04.2010. 16:14 ] @
Posto si napravio svoj konstruktor za studenta ( Student(const char*,int,const char*); ), defaultni se "brise" tako da moras i njega napraviti.
Sad samo napravi defaultni konstruktor u Studentu ( Student(){ // ... } ), jer se isti poziva u defaultnom konstruktoru klase Cvor. Zbog toga sto u njoj postoji element klase student.