您能否幫我理解我在做什麼錯誤。 我有NetBeans,MinGW編譯器和Qt庫。'Figure :: Figure()'的原型不匹配'圖'
* Figure.h *
class Figure: public QObject{ //18
Q_OBJECT
public:
Figure(); //32
};
Figure.cpp
Figure:: Figure(){ // 16
}
錯誤消息:
Figure.h:18:7: error: candidates are: Figure::Figure(const Figure&)
Figure.h:32:17: error: Figure::Figure()
Figure.cpp:16:1: error: prototype for 'Figure::Figure()' does not match any in class 'Figure'
通過順便說一下,我試圖按照這個Figure(const Figure&)
模式。它沒有工作。
以後添加(更多代碼有人問):
Figure.h
#ifndef FIGURE_H
#define FIGURE_H
#include <QtGui/QApplication>
#include <QFrame>
#include <initializer_list>
#pragma once
enum colours {RED, GREEN, BLUE, YELLOW, MAGENTA};
class Figure: public QObject{
Q_OBJECT
public:
int shape[4][4];
private:
int previous_shape;
int current_shape;
int current_x;
int current_y;
int previous_x;
int previous_y;
colours colour;
public:
Figure();
int testint;
int test[2];
void change_figure();
void roll_back();
void set_coordinates(int direction);
void set_colour();
void rotate();
int get_x();
int get_y();
int* get_shape();
// signals:
// void transmitInfo();
};
Figure.cpp
#include "Figure.h"
#include <cstdlib>
#include <QtGui>
#include <QtGui/QApplication>
#include <iostream>
#include <initializer_list>
template <class T>
Figure:: Figure(){
//shape = {{1, 1}, {1, 1}};
previous_shape = 1;
current_shape = 1;
current_x = 5;
current_y = 5;
previous_x = 5;
previous_y =5;
colour = RED;
}
Q_OBJECT是如何定義的? – 2013-05-09 19:11:16
你可以更新你的文章幷包含整個Figure.h和Figure.cpp嗎? – kenrogers 2013-05-09 19:14:26
@Scott Jones,Q_OBJECT是一個Qt宏。 – Trts 2013-05-09 19:20:37