2012-01-24 50 views
0

我真的不知道爲什麼我有這個重新定義錯誤重新定義 「類GtkwidgetDef」 的

GtkwidgetDef.h

#include <gtk/gtk.h> 
class GtkwidgetDef 
{ 
public: 
    GtkWidget* display; 
    GtkwidgetDef(GtkButton* button); 
}; 

GtkwidgetDef.cpp

#include "GtkwidgetDef.h" 
extern "C" GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widgetName); 

GtkwidgetDef::GtkwidgetDef(GtkButton* button){ 
display = lookup_widget(GTK_WIDGET(button), "display"); 
} 

這兩個fonctions是中庸之道定義和構造函數

MesFonctions.cpp

#include "MesFonctions.h" 
#include <math.h> 
string str; 
gchar str1[9] = ""; 

void showText(GtkwidgetDef widgets, gchar* label) 
{ 
gtk_entry_set_text(GTK_ENTRY(widgets->display), label); 
} 
......... 

CALCU.h

#include <gtk/gtk.h> 
typedef enum Event{ SEVEN_CLICKED, PLUS_CLICKED, VALIDE } Event; 

int processEvent(Event e, GtkButton* button); 

CALCU.cpp

#include "CALCU.h" 
#include "MesFonctions.h" 
#include "GtkwidgetDef.h" 

int processEvent(Event e, GtkButton* button) 
{ 
//GtkwidgetDef* widgets = new GtkwidgetDef(); 
//label = gtk_button_get_label(button); 
GtkwidgetDef widgets(button); 
gchar* label; 
strcpy(label, gtk_button_get_label(button)); 

string s; 
switch(e) 
{ 
    case SEVEN_CLICKED: 
     //showText(*widgets, label); 
     showText(widgets, label); 
     s = "7"; 
     pushValue(s); 
     break; 
    case PLUS_CLICKED: 
     //showText(*widgets, label); 
     showText(widgets, label); 
     s = "+"; 
     pushValue(s); 
     break; 
    case VALIDE: 
     showResult(); 
     break; 
} 
} 

我不知道我在這一行GtkwidgetDef小部件(按鈕)犯錯誤這裏;

+0

您能否顯示您的''MesFonctions.h「'文件? – dasblinkenlight

回答

1

我認爲你看到這個的原因是你在某個時候包含了兩次GtkwidgetDef.h:一次是直接的,一次是間接的。您可能需要在您的標題中添加include guard

#ifndef GtkwidgetDef_h 
#define GtkwidgetDef_h 

#include <gtk/gtk.h> 
class GtkwidgetDef 
{ 
public: 
    GtkWidget* display; 
    GtkwidgetDef(GtkButton* button); 
}; 

#endif