Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ “重新定义”;“GtkwidgetDef”类;_C++_Gtk_Redefinition - Fatal编程技术网

C++ “重新定义”;“GtkwidgetDef”类;

C++ “重新定义”;“GtkwidgetDef”类;,c++,gtk,redefinition,C++,Gtk,Redefinition,我真的不知道为什么我会有这种重新定义的错误 GtkwidgetDef.h #include <gtk/gtk.h> class GtkwidgetDef { public: GtkWidget* display; GtkwidgetDef(GtkButton* button); }; 这两个函数是justedefinition和constructor MesFonctions.cpp #include "MesFonctions.h" #include <ma

我真的不知道为什么我会有这种重新定义的错误

GtkwidgetDef.h

#include <gtk/gtk.h>
class GtkwidgetDef
{
public:
    GtkWidget* display;
    GtkwidgetDef(GtkButton* button);
};
这两个函数是justedefinition和constructor

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);
}
.........

我想知道我是否在这一行GtkwidgetDef小部件(按钮)中出错

我认为您之所以看到这一点,是因为您在某个点包含了
GtkwidgetDef.h
两次:一次直接,一次间接。您可能需要在标题中添加:

#ifndef GtkwidgetDef_h
#define GtkwidgetDef_h

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

#endif
#ifndef GtkwidgetDef#h
#定义GtkwidgetDef_h
#包括
类GtkwidgetDef
{
公众:
GtkWidget*显示;
GtkwidgetDef(GTK按钮*按钮);
};
#恩迪夫
您能否同时显示您的
“MesFonctions.h”
文件?
#include <gtk/gtk.h>
typedef enum Event{ SEVEN_CLICKED, PLUS_CLICKED, VALIDE } Event;

int processEvent(Event e, GtkButton* button);
#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;
}
}
#ifndef GtkwidgetDef_h
#define GtkwidgetDef_h

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

#endif