Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKhatharr

Posted 27 November 2012 - 10:25 PM


Firstly, I am using inheritance correctly. The base class is virtual so LSP doesn't really apply

Hmm. I am having an awful lot of trouble getting those three statements to align correctly.


Substitutability is a principle in object-oriented programming. It states that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substituted for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).


A virtual class cannot be instantiated.
[source lang="cpp"]class Scene {public: virtual ~Scene() {}; virtual int initialize() = 0; virtual int update() = 0; SceneID ident;};[/source]
If I'm gonna use a derived class from that then it's going to have different functionality.

LSP applies in situations where the base actually has functionality. It requires that inheritors correctly implement the appropriate behavior as the base would.

#1Khatharr

Posted 27 November 2012 - 10:15 PM


Firstly, I am using inheritance correctly. The base class is virtual so LSP doesn't really apply

Hmm. I am having an awful lot of trouble getting those three statements to align correctly.


Substitutability is a principle in object-oriented programming. It states that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substituted for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).


A virtual class cannot be instantiated.

PARTNERS