Questions tagged [subclassing]

A subclass, "derived class", heir class, or child class is a modular, derivative class that inherits one or more language entities from one or more other classes.

A subclass, "derived class", heir class, or child class is a modular, derivative class that inherits one or more language entities from one or more other classes (called superclasses, base classes, or parent classes). The semantics of class inheritance vary from language to language, but commonly the subclass automatically inherits the instance variables and member functions of its superclasses. Some languages support the inheritance of other construct as well. For example, in Eiffel, contracts which define the specification of a class are also inherited by heirs. The superclass establishes a common interface and foundational functionality, which specialized subclasses can inherit, modify, and supplement. The software inherited by a subclass is considered reused in the subclass. A reference to an instance of a class may actually be referring one of its subclasses. The actual class of the object being referenced is impossible to predict at compile-time. A uniform interface is used to invoke the member functions of objects of a number of different classes. Subclass may replace superclass functions with entirely new functions that must share the same method signature.

833 questions
-2
votes
1 answer

PHP child class' function override is not being called

EDIT: As requested by @hakre, here is a simplified version of the parent class. See below that for the full, original question. class WebsitePage { protected $name; protected $slug; protected $heading; protected $intro; protected…
Kenny83
  • 769
  • 12
  • 38
-2
votes
1 answer

How can i update class variable by calling a class method from a derived class

I am developing a package for my testing purpose called dbtest. This package is because i am using MySQLdb for connecting databases and hence it is very tedious task to write sql queries while testing. So i created a new package and all queries can…
vishnu m c
  • 841
  • 1
  • 7
  • 21
-2
votes
2 answers

How to call functions from one subclass to another subclass

class Acct: def __init__(self, deposit): self.balance = deposit def balance(self): print("Your balance is $",self.balance) def getDeposit(self, deposit): self.balance = self.balance + deposit print("Your…
-3
votes
2 answers

In C++, is a "public unsigned int type" in base class, a faster alternative to dynamic_cast?

In C++, "dynamic_cast" being slow is a known fact. I thought of following simple way of knowing the type of an object in a hierarchy. Could someone please explain if this could be slower than dynamic_cast? And if not, then why isn't it a common…
-3
votes
1 answer

Protocol and Subclassing In Swift, self does not mean current object

protocol ManagerDelegate: class { func manager(_ manager: ManagerProtocol, didDealWith trouble: String) -> Void } protocol ManagerProtocol: class { weak var delegate: ManagerDelegate? { get set } } private class Wrapper { weak var…
mlibai
  • 31
  • 5
-3
votes
2 answers

Accessing Subclass Methods and Instances From Within a Method With A Superclass Parameter

Novice Java programmer here... So I have this superclass: public abstract class Animal { public abstract String attack(Animal entity); } and then I have this subclass: public class Dog extends Animal { protected int something; …
user3370603
  • 87
  • 1
  • 8
-3
votes
1 answer

Subclassing in Python

Is it possible to subclass dynamically? I know there's ____bases____ but I don't want to effect all instances of the class. I want the object cf to polymorph into a mixin of the DrvCrystalfontz class. Further into the hierarchy is a subclass of…
Scott
  • 5,135
  • 12
  • 57
  • 74
-4
votes
1 answer

Can't click on controls/menu when detach MDI child out of MDI client area

Whole sample project can be found here: Sample project Normal MDI child: MDI child is detached out of MDI client area: Problem is after MDI child is detached, I am not able to click on menu/controls anymore. I think one approach is to subclass…
MarkJoy
  • 55
  • 6
1 2 3
55
56