S
S
sddvxd2018-04-01 14:43:19
C++ / C#
sddvxd, 2018-04-01 14:43:19

What is wrong here (constructor)?

Hello
class code:

class Queue{
private:
  struct Node
  {
    String str = "123";
    Node* next;
  };
  enum{
    Q_SIZE = 10
  };
  int items;
  const int qsize;
  Node * front,rear;
public:
  Queue(int);
  bool isfull()const;
};

Queue constructor:
Queue::Queue(int qs = Q_SIZE):qsize(qs),front(nullptr),rear(nullptr),items(0){}

Compiler responds:
No match for function call `Queue::Node::Node(int)`

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlov, 2018-04-01
@sddvxd

Error on this line:
Only frontis a pointer to a structure. In the class constructor, you pass rear- to the constructor . There will be no error if both values ​​are pointers:int (nullptr)
Node *front, *rear;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question