0
의 C++ LinkedList의 :이 같은 형태의 목록을 인스턴스화하는 것을 시도하고 사용자 정의 클래스 오류
this LinkedList의 라이브러리를 사용LinkedList<Shape> *shapes = new LinkedList<Shape>();
. 내 Arduino에 대한 Platformio 사용하여 컴파일하고 업로드 할 수 있습니다.
프로그램을 컴파일하려고 할 때 계속 오류가 발생합니다. 나는 전에 아무 깃발도 얻지 않는다. 내가 사용하는 구조체와 함께 잘 작동하므로 LinkedList 라이브러리에 문제가 있다고 생각하지 않습니다. POS
. 문제는 Shape::Shape(...)
생성자와 관련이있는 것으로 보입니다.
그것은 중요하지 않을해야하지만,의 Shape
클래스가 하나의 목록에서 특정 Shape
어린이의 혼합을 허용하는 간단한 부모 클래스 : Circle
, Ellipse
, Line
등
// POS
struct POS {
int x;
int y;
};
// Shape.h
#ifndef SHAPE_H
#define SHAPE_H
#include "../stepper/POS.h"
#include "../Drive.h"
class Drive;
class Shape {
public:
Drive *_drive;
Shape(Drive *drive);
~Shape();
POS draw();
};
#endif
//Shape.cpp
#include "Shape.h"
class Drive;
Shape::Shape(Drive *drive): _drive(drive){};
Shape::~Shape() {
delete _drive;
};
POS Shape::draw(){
return _drive->get();
};
오류 :
[Thu Sep 14 19:51:04 2017] Processing uno (platform: atmelavr; lib_deps: LinkedList; board: uno; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 25 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <LinkedList>
|-- <Servo> v1.1.2
Compiling .pioenvs/uno/src/Project/main.o
In file included from src/Project/main.cpp:4:0:
.piolibdeps/LinkedList_ID443/LinkedList.h: In instantiation of 'bool LinkedList<T>::add(int, T) [with T = Shape]':
src/Project/main.cpp:50:1: required from here
.piolibdeps/LinkedList_ID443/LinkedList.h:184:37: error: use of deleted function 'ListNode<Shape>::ListNode()'
ListNode<T> *tmp = new ListNode<T>(),
^
.piolibdeps/LinkedList_ID443/LinkedList.h:19:8: note: 'ListNode<Shape>::ListNode()' is implicitly deleted because the default definition would be ill-formed:
struct ListNode
^
.piolibdeps/LinkedList_ID443/LinkedList.h:19:8: error: no matching function for call to 'Shape::Shape()'
.piolibdeps/LinkedList_ID443/LinkedList.h:19:8: note: candidates are:
In file included from src/Project/shapes/Circle.h:3:0,
from src/Project/main.cpp:7:
src/Project/shapes/./Shape.h:11:5: note: Shape::Shape(Drive*)
Shape(Drive *drive);
^
src/Project/shapes/./Shape.h:11:5: note: candidate expects 1 argument, 0 provided
src/Project/shapes/./Shape.h:8:7: note: constexpr Shape::Shape(const Shape&)
class Shape {
^
src/Project/shapes/./Shape.h:8:7: note: candidate expects 1 argument, 0 provided
In file included from src/Project/main.cpp:4:0:
.piolibdeps/LinkedList_ID443/LinkedList.h: In instantiation of 'bool LinkedList<T>::add(T) [with T = Shape]':
src/Project/main.cpp:50:1: required from here
.piolibdeps/LinkedList_ID443/LinkedList.h:199:37: error: use of deleted function 'ListNode<Shape>::ListNode()'
ListNode<T> *tmp = new ListNode<T>();
^
.piolibdeps/LinkedList_ID443/LinkedList.h: In instantiation of 'bool LinkedList<T>::unshift(T) [with T = Shape]':
src/Project/main.cpp:50:1: required from here
.piolibdeps/LinkedList_ID443/LinkedList.h:225:37: error: use of deleted function 'ListNode<Shape>::ListNode()'
ListNode<T> *tmp = new ListNode<T>();
^
Linter
Severity Provider Description Line
PIO Buildsrc/Project/shapes/Shape.cpp00011:19
LFUTF-8C++master+141 update
기본 생성자'Shape()'이 필요하지만'Shape (Drive *) '드라이브를 사용하는 생성자 만 있습니다. 매개 변수를 사용하지 않는'Shape()'생성자를 추가해야합니다. –
@SteveLorimer, yup, 그것을 고정 시켰습니다. 나는 바보입니다. 모든 공평성에서 C++은 내 강한 소송이 아닙니다. – Drew