0

Are there specific methods or methods are just functions in classes and when we define them write what they do?

8th Jan 2019, 9:46 AM
Platinoob_
Platinoob_ - avatar
3 Answers
+ 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
8th Jan 2019, 10:12 AM
Gordon
Gordon - avatar
+ 1
The operators are specific methods and just functions in classes that we write what they do, aren't they?
8th Jan 2019, 9:55 AM
Bebida Roja
Bebida Roja - avatar
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
8th Jan 2019, 11:29 AM
Denis Cvetanov
Denis Cvetanov - avatar