0
What's the difference between interface and abstract class?
7 Answers
+ 2
just to add, when you just want to hide everything from user; you use interface... best example is ATM machine main window.. based on type of ATM card you insert, it creates object of different banks and ask you logical questions based on different banks in different sequence.. same ATM asks different questions if you insert SBI or icicic card... here main class is interface and no method should be implemented here...
this is my thought ... I am just giving you example which best suits interface based on my knowledge...
+ 1
Girish L V in c++, abstract class must have atleast one pure virtual method which will be implemented in other class... Abstract class may have other method implemented in same class rather than making it pure virtual..
for interface, there is no method implemented in class.. all methods should be implemented in other classes and one should make all methods as pure virtual..
I am unaware about java...
+ 1
it depends on your requirement...
class Bank()
{
public:
int SetMinBalanceReq() = 0;
};
class Bank1()
{
public:
int SetMinBalanceReq() = 0;
void SetAccDetail()
{
//your code
}
};
refer above and observe that bank class is interface as it has no implemented method...
bank1 is abstract class as it has one pure virtual method along with implemented method
minbalance is to be implemented in different class based on account type...
+ 1
thank you so much
+ 1
happy to help... feel free to ask if you have question... will try best to let you know...
0
do you know any example for both interface and abstract class
0
are you from?