error: expected class-name before '(' token

So, where I have to declare the virtual destructor, I have this error
error: expected class-name before '(' token . I don't understand what's happening.


#ifndef BOARD_H
#define BOARD_H

const int SIZE = 3;

struct Board
{
public:
virtual void Next()=0;
virtual int CountValues()=0;
};


#endif // BOARD_H

#ifndef BOARDIMPL_H
#define BOARDIMPL_H

#include "board.h"

class BoardImpl: public Board
{
void Print() const;

protected:
int _board[SIZE];

public:

BoardImpl();
void Next();

int CountValues();


// TODO: 04. to declare the virtual destructor

virtual void ~Next();
virtual void ~CountValues();

protected:

virtual void Init();

int RandomValue();
};

#endif // BOARDIMPL_H



What are you trying to "destruct" with these?
1
2
virtual void ~Next();
virtual void ~CountValues();
A class can only have one destructor. It must be named ~ followed by the name of the class, and it can't have a return type.

A virtual destructor for the Board class would look like virtual ~Board();
And now i have an another error: declaration of '~Board' as member of 'BoardImpl'.
Member function ~Board() goes in class Board
Member function ~BoardImpl() goes in class BoardImpl

The destructor has the same name as the class it is in and is prefixed by a ~
Thank you
Topic archived. No new replies allowed.