Witam,
Podczas dokładania kolejnych plików do projektu napotkałem błąd, z którym nie mogę sobie poradzić.
error: multiple definition of `plikwynik2'
C:/Qt/2009.04/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h::-1:
error: multiple definition of `tab1'
C:/Qt/2009.04/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h::-1:
error: multiple definition of `tab2'
C:/Qt/2009.04/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h::-1:
error: collect2: ld returned 1 exit status:-1:
Pojawił się po dopisaniu do mainwindow.cpp: #include “funkcje.hpp” mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
void WczytajDane();
public slots:
void pb_start_clicked();
void pb_zakoncz_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "funkcje.hpp"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
WczytajDane();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::pb_start_clicked()
{
ui->plainTextEdit->appendPlainText("jakis tekst");
}
void MainWindow::pb_zakoncz_clicked()
{
qApp->quit();
}
void MainWindow::WczytajDane()
{
}
funkcje.hpp
#ifndef _funkcje_hpp_
#define _funkcje_hpp_
#include
#include
using std::vector;
using std::string;
struct dane
{
int ile;
vector w;
};
string plikwynik2;
bool **tab1;
unsigned *tab2;
int liczba;
string wyswietl_dane( dane &x );
#endif
funkcje.cpp
#include
#include
#include
using std::vector;
using std::string;
string wyswietl_dane( dane &x )
{
string s = "";
unsigned i=1;
for(vector::iterator it=x.w.begin(); it < x.w.end(); it++, i++)
if(*it)
s += i + " \t";
return s;
}
Ten błąd pojawia się tylko przy deklaracji wskaźników w pliku funkcje.hpp. Przy deklaracji ‘int liczba;’ błędu już nie ma.
Jak poradzić sobie z usunięciem tego błędu?