How to declare an interface in C++? (pure virtual functions and abstract classes)
Hello! I just started learning C++ after Java, and I'm very confused by the absence of the `interface` keyword, like in Java or C#. In Java, I'm used to doing this:
```java
public interface Drawable {
void draw();
void resize(int width, int height);
}
```
But in C++, I can't find a direct analog. I know that C++ has abstract classes with pure virtual functions, but I'm not sure how to properly declare and use them.
For example, I tried writing this code:
```cpp
class Drawable {
public:
virtual void draw() = 0;
virtual void resize(int width, int height) = 0;
};
```
But I have some questions:
1. Do I need to add a virtual destructor? If yes, should it be pure virtual?
2. Do I need to prevent copying of objects of such a class?
No answers yet.
Log in to leave an answer