I have some questions about interfaces in C++.
As far as I understand them, they are used if you want to use a base-class with certain tasks that you already have in mind and you declare some methods for that (but without definition). But every derived class needs to implement these methods for their specific purpose so you create them as abstract methods. And the only difference between abstract classes and interfaces is, that abstract classes have atleast one pure virtual method but also some "normal" methods and interfaces have only pure virtual methods. Is that right?
My professor described interfaces as a way of two classes to communicate with each other. E.g. one interface for a network class and one for an analyzer class who analyzes information from that network. But why do I need an interface for that? Couldn't I just use a normal class for that instead a class which is derived from an interface? He made it sound that in order to extract information from another class you need to have a interface-derived class. Is there any benefit from using an interface here?
I hope my question is clear, English is not my first language.
EDIT: Abstract class: (1/3 methods are pure virtual)
class MyAbstractClass {
public:
virtual ~MyAbstractClass() {}
virtual void Method1();
virtual void Method2();
virtual void Method3() = 0;
};
Interface: (all methods are pure virtual)
class MyInterface {
public:
virtual ~MyInterface() {}
virtual void Method1() = 0;
virtual void Method2() = 0;
};