2012-01-24 58 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