tags:

views:

66

answers:

1

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?

+3  A: 

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
Haspemulator