Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.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++ Arduino 1.6.3没有用于调用的匹配函数_C++_Arduino - Fatal编程技术网

C++ Arduino 1.6.3没有用于调用的匹配函数

C++ Arduino 1.6.3没有用于调用的匹配函数,c++,arduino,C++,Arduino,尝试创建一些内联帮助器类,然后显示图形。 今年夏天编写了一些代码,然后进行编译,现在运行最新的arduino时却没有 错误: tmp.ino: In constructor 'Image::Image(Rectangle, String, String, String, String, String, String, String, String, String, String)': tmp.ino:24:187: error: no matching function for call to

尝试创建一些内联帮助器类,然后显示图形。 今年夏天编写了一些代码,然后进行编译,现在运行最新的arduino时却没有

错误:

tmp.ino: In constructor 'Image::Image(Rectangle, String, String, String, String, String, String, String, String, String, String)':
tmp.ino:24:187: error: no matching function for call to 'Rectangle::Rectangle()'
tmp.ino:24:187: note: candidates are:
tmp.ino:11:5: note: Rectangle::Rectangle(int, int, int, int)
tmp.ino:11:5: note:   candidate expects 4 arguments, 0 provided
tmp.ino:3:7: note: Rectangle::Rectangle(const Rectangle&)
tmp.ino:3:7: note:   candidate expects 1 argument, 0 provided
Error compiling.
tmp.ino:20:1: error: 'rect' does not name a type
Error compiling.
下面是一个例子:

class Rectangle {
  private:
  public:
    int x;
    int y;
    int width;
    int height;

    Rectangle(int ix, int iy, int iwidth, int iheight) {
      x = ix;
      y = iy;
      width = iwidth;
      height = iheight;
    }
};

class Image {
  private:
  public:
    Rectangle bounds;
    String images[10];
    Image(Rectangle s_bounds, String s1, String s2 = "", String s3 = "", String s4 = "", String s5 = "", String s6 = "", String s7 = "", String s8 = "", String s9 = "", String s10 = "") {
      bounds = s_bounds;

      images[0] = s1;
      images[1] = s2;
      images[2] = s3;
      images[3] = s4;
      images[4] = s5;
      images[5] = s6;
      images[6] = s7;
      images[7] = s8;
      images[8] = s9;
      images[9] = s10;

    }
    void UpdatePosition( int s_x, int s_y ) {
      bounds.x = s_x;
      bounds.y = s_y;
    }
};


void setup() {
  // put your setup code here, to run once:
  Rectangle rect = Rectangle(0,0,200,29);
  rect.x = 20;

  Image img = Image(Rectangle(0,0,10,10), "img.RAW");
}

void loop() {
  // put your main code here, to run repeatedly:

}

在最新的arduino中是否对此进行了一些更改。尝试创建简单矩形时

错误:

tmp.ino: In constructor 'Image::Image(Rectangle, String, String, String, String, String, String, String, String, String, String)':
tmp.ino:24:187: error: no matching function for call to 'Rectangle::Rectangle()'
tmp.ino:24:187: note: candidates are:
tmp.ino:11:5: note: Rectangle::Rectangle(int, int, int, int)
tmp.ino:11:5: note:   candidate expects 4 arguments, 0 provided
tmp.ino:3:7: note: Rectangle::Rectangle(const Rectangle&)
tmp.ino:3:7: note:   candidate expects 1 argument, 0 provided
Error compiling.
tmp.ino:20:1: error: 'rect' does not name a type
Error compiling.
代码:

您有一个矩形作为图像类的一部分,并且没有在初始化列表中构造它,因此它默认为获得默认构造,并且您没有默认构造函数

您需要使用在初始化列表中传入的矩形初始化矩形:

Image(Rectangle s_bounds, String s1, String s2 = "", String s3 = "", String s4 = "", String s5 = "", String s6 = "", String s7 = "", String s8 = "", String s9 = "", String s10 = "")
 : bounds(s_bounds)
{
  images[0] = s1;
  images[1] = s2;
  images[2] = s3;
  images[3] = s4;
  images[4] = s5;
  images[5] = s6;
  images[6] = s7;
  images[7] = s8;
  images[8] = s9;
  images[9] = s10;

}

第二个问题似乎是因为您试图在函数之外的全局命名空间中编写代码,这是无效的。当我把它移到main时,它运行得很好。

这就像一个符咒。将尝试在arduino之外创建课程作为图书馆,只是为了获得一些培训。这真的很有帮助。