Hour 17

   

1:

In what cases would you use interfaces as opposed to regular class inheritance? Why would you use class inheritance instead of interfaces?

A1:

One of the biggest distinctions that arises is that of inheritance. If you have a group of unrelated classes that need to share a common convention, such as a certain protocol, you should use interfaces. However, in order to maintain an "is-a" relationship among objects as you progress up and down an inheritance hierarchy, you should use classes.

2:

Can you add an implementation for any of the .NET Framework interfaces?

A2:

Yes, interfaces always have a public access specifier.

3:

Can an interface contain private or protected methods and/or properties?

A3:

No, an interface can only contain public methods and properties.

4:

Can an interface contain data members instead of properties?

A4:

No, only properties are allowed.

5:

Can you obtain an interface pointer from one object and then cast it to the same interface type but from a different object?

A5:

Yes, as long as the second object implements that interface.


   
Top


Sams Teach Yourself Visual C++. NET in 24 Hours
Sams Teach Yourself Visual C++.NET in 24 Hours
ISBN: 0672323230
EAN: 2147483647
Year: 2002
Pages: 237

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net