0
Are there specific methods or methods are just functions in classes and when we define them write what they do?
3 ответов
+ 2
What you describe is behavior of an interface instead of class.
Java allows interface
https://www.sololearn.com/learn/Java/2167/?ref=app
For C++, it is called Pure Virtual Class https://www.sololearn.com/learn/CPlusPlus/1912/?ref=app
+ 1
The operators are specific methods and just functions in classes that we write what they do, aren't they?
0
Methods are just functions in classes, but it is not necessary for us to write all of them. Many are predefined for us to use in the libraries we include.
For an example you could create your own method in a class which let's say prints it's contents.
But you could also predefine a method or operators for your own class.
You can see in the following code how i overload the operator = method to be suitable for my class. You can do that with almost every element if you know how 😉😊
https://code.sololearn.com/ckIETr5ecdzB/?ref=app