Hi when i try to run c++ code I am getting the following error
mainwindow.h
class MainWindow
{
public:
MainWindow();
~MainWindow();
method(开发者_运维技巧);
};
and
mainwindow.cpp
#include mainwindow.h
MainWindow::MainWindow(){
//some code here
}
MainWindow::~MainWindow(){
//some code here
}
MainWindow::method(){
//some code here
}
when i compile this from eclipse cdt i got the error saying multiple defintion of MainWindow::method()
.
Is this the correct way or iam doing anything wrong.
Can any one please help me what to do?
It seems that you include your header in several cpp, and it has no guard preventing from multiple includes, like pragma once
or
#ifndef MainWindow_h
#define MainWindow_h
class MainWindow
{
public:
MainWindow();
~MainWindow();
method();
};
#endif
精彩评论