0

Can i define a FUNCTION in a class and If yes then how can i access on an object or it is not possible to define a function??

Or it is only allowed to define method in a class??

31st Mar 2017, 6:52 AM
PREETAM
PREETAM - avatar
3 Answers
+ 1
Yes, you can define functions inside class. For python, it is simple by def func().. You access it with . notation, such as obj.func(). But it is possible for public functions, if you want to access them outside the class.
31st Mar 2017, 7:01 AM
Syed Muhammad Dawoud Sheraz Ali
Syed Muhammad Dawoud Sheraz Ali - avatar
0
For example??
31st Mar 2017, 7:36 AM
PREETAM
PREETAM - avatar
0
A function in a class is CALLED a method. The difference is just the vocabulary.
31st Mar 2017, 9:31 PM
Amaras A
Amaras A - avatar