Have some problems with the qt destructor.
I'm working on QtCreator:
here's the class:
the .cpp

#include "controller.h"

Controller::Controller()
{
}
Controller::Controller(MovieRepo *movrep, MovieValidator *movval){
    this->movrep=movrep;
    this->movval=movval;
}

void Controller::addMov(int id, string title, string desc, string type)throw(ValidatorException){
    Movie* mov=new Movie(id, title, desc, type);
    movval->validate(*mov);
    movrep->store(*mov);
}

const Movie* Controller::getById(int id){
    return movrep->getById(id);
}

vector<Movie*> Controller::getAll(){
    return movrep->getAll();
}

int Controller::getSize (){
    return movrep->getnr ();
}

int Controller::findbyid (int id){
    vector<Movie*> obj=movrep->getAll();
    for (int i=0;i<getSize ();i++){
        if (id=obj[i]->getId()){
            return i;
        }
    }
    return NULL;
}

void Controller::open(){
    ifstream fin("MovRep.txt", ios::in);
    string line;
    if (!fin){
        ofstream fm ("MovRep.txt");
    }
    else{
        while (getline(fin, line)){
            istringstream tokenizer(line);
            string title, desc, type;
            getline(tokenizer,title,',');
            istringstream int_iss(title);
            int id;
            int_iss>>id;
            getline(tokenizer, title, ',');
            getline(tokenizer, desc, ',');
            getline(tokenizer, type, ',');
            if (!movrep->dup(id)){
                addMov(id, title, desc, type);
            }
        }
    }
}

void Controller::save(){
    ofstream fin ("MovRep.txt");
    vector<Movie*>all=getAll();
    for (int i=0;i<(int)all.size();i++){
        fin<<all[i]->getId()<<","<<all[i]->getTitle()<<","<<all[i]->getDesc()<<","<<all[i]->getType()<<"\n";
    }
}

void Controller::del(int id)throw (ValidatorException){
    if (movrep->dup(id)){
        throw ValidatorException("Invalid id.");
    }
    movrep->del(id);
}

Controller::~Controller(){
    delete [] movrep;
    delete [] movval;
}

and the .h

#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <string>
#include "movie.h"
#include "movierepo.h"
#include "fstream"
#include <sstream>
#include "movievalidator.h"
class Controller
{
    MovieRepo* movrep;
    MovieValidator* movval;
public:
    Controller();
    Controller(MovieRepo* movrep, MovieValidator* movval);
    void addMov(int id, string title, string desc, string type) throw (ValidatorException);
    vector<Movie*> getAll();
    const Movie* getById(int id);
    int findbyid(int id);
    int getSize();
    void open();
    void save();
    void del(int id) throw (ValidatorException);
    ~Controller();
};

#endif // CONTROLLER_H

and i receive this error:
c:\qtcreatorworkspace\proj2\controllemovierepo.obj:-1: error: LNK2019: unresolved external symbol "public: int __thiscall MovieRepo::findbyid(int)" (?findbyid@MovieRepo@@QAEHH@Z) referenced in function "public: void __thiscall MovieRepo::del(int)" (?del@MovieRepo@@QAEXH@Z)
r.h:23: warning: C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
What is there to be done?

nevermind, it seemed that i had to add this line:

QT       += network

in the .pro file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.