|
-
December 10th, 2008, 05:48 PM
#6
Re: abstract class
pure virtual function declaration provide the prototype of the method. but an implementation of the pure virtual function is typically not provided in an abstract class (in 99% of situations), but it may be included. Every non-abstract child class is still required to override the method, but the implementation provided by the abstract class may be called in this way:
Code:
class Abstract {
public:
virtual void pure_virtual() = 0;
};
void Abstract::pure_virtual() {
// do something
}
class Child : public Abstract {
virtual void pure_virtual(); // no longer abstract, this class may be
// instantiated.
};
void Child::pure_virtual() {
Abstract::pure_virtual(); // the implementation in the abstract class
// is executed
}
this is the flexibility of C++ but i am not sure we can do such thing in C#!
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|