0

When i try to make a function in private and define it outside class it gives me error why so??

class abc { private : void disp(); //some code }; void abc :: disp() { //some code }

24th Dec 2017, 6:57 AM
Prarthit Mehra
4 odpowiedzi
+ 2
If you want to access the method from outside the class, then you must use public instead of private.
24th Dec 2017, 8:39 AM
Bagshot
Bagshot - avatar
+ 1
You cannot access private methods from outside. At all. What you could do is make a public method to access the private method.
24th Dec 2017, 9:05 AM
blackcat1111
blackcat1111 - avatar
0
so if at all i want to declare a function in private i will have to define it there in the class in private itself right??
24th Dec 2017, 11:08 AM
Prarthit Mehra
- 1
This works with my compiler.
24th Dec 2017, 1:37 PM
Timon Paßlick