Questions tagged [base-class]

In Object Oriented Programming, a base class is one from which other classes inherit. For example, a child-class `Male` and another child-class `Female` may both inherit from the base-class `Human`.

In Object Oriented Programming, a base class is one from which other classes inherit. For example, a child-class Male and another child-class Female may both inherit from the base-class Human. As a result of such an inheritance, each of them will have at least all the attributes and methods of the class Human and perhaps a few others.

678 questions
5
votes
1 answer

Generic Entity Base Class

I've just read a post about Generic Entity Base Classes. Simply and if I'm not wrong, the main idea in behind is collecting all generic, non-entity-spesific fields in one interface, than implement it in main entities. It's going to be a TL:DR; Let's…
Uğur Cem Öztürk
  • 330
  • 1
  • 3
  • 14
5
votes
2 answers

Scope of derived class in base class - Inheritance in python

I know that by inheriting the base class. All the functions in base class would be accessible in the derived class as well. But how does it work the other way, meaning can a function that is defined in the child class be accessible in the base…
Abhishek
  • 155
  • 3
  • 14
5
votes
3 answers

how to implement casting to a private base class in C++

How to implement casting to a private base class in C++? I don't want to use hacks such as adding a friend etc. Defining public casting operator does not work. EDIT : For example I have: class A { //base class } class AX : private A { //a…
user283145
5
votes
4 answers

How do you work with a variable that can be of multiple types?

I frequently link objects to their parents using: Video parent; Sometimes I have objects that can be children of different object types, so do I: int parentType; Video parentVideo; // if parent == VIDEO then this will be used Audio parentAudio;…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
5
votes
2 answers

Can a non-object exist in Python?

As everyone knows, everything is an object in Python. What I'm wondering about is whether it's possible to create an "object" x such that isinstance(x, object) returns False. I suspect it's possible with sufficient abuse of the CPython API, though…
nneonneo
  • 171,345
  • 36
  • 312
  • 383
5
votes
4 answers

C++ convert base class pointer to derived class, without knowing derived class

I have various types of collider classes (SphereCollider, AABBCollider etc), all inheriting from the base class Collider. I store them using a pointer to the base class in a std::vector. std::vector> colliders; I then have…
sangwe11
  • 123
  • 6
5
votes
1 answer

How to add global variables used by all tests in Javascript?

I could not find how to remove code duplication in Javascript (basically what I would achieve in Java with base classes). The concrete example is (at least) the following code, which is common to all spec files (and potentially page objects, since I…
5
votes
5 answers

Concise (yet still expressive) C++ syntax to invoke base class methods

I want to specifically invoke the base class method; what's the most concise way to do this? For example: class Base { public: bool operator != (Base&); }; class Child : public Base { public: bool operator != (Child& child_) { …
sivabudh
  • 31,807
  • 63
  • 162
  • 228
5
votes
1 answer

How to make user control partial classes aware of controls declared in the base class?

Do we have to do something special to have ASP.NET partial classes aware of controls that are declared in our user control's base classes? The partial classes keep generating declarations for controls in the base class which mean the controls in the…
Helephant
  • 16,738
  • 8
  • 39
  • 36
5
votes
3 answers

What is the use of Template Method in Base Classes?

Well, I was going through this excellent article on MSDN about "Base Class Usage". While I understand the concept of base class and interfaces, I am unable to comprehend the usage of Template methods in the second paragraph of this article…
Aakash
  • 695
  • 3
  • 10
  • 25
5
votes
1 answer

ASP.NET CodeFileBaseClass attribute vs. inherit from System.Web.UI.Page

I've just created a base class for my pages by inheriting from System.Web.UI.Page: public abstract class PageBase : System.Web.UI.Page { ... } When I noticed that you can also declare a base page in an ASP.NET view: <%@ Page Language="C#"…
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
5
votes
2 answers

Calling identically named methods in base classes

Base class A has a subclass B, and B has a subclass C. A implements a virtual method doStuff(), B does not, and C does. From C, I want to call A's implementation of doStuff() (I do this from within C's implementation of doStuff() but that shouldn't…
Luke
  • 7,110
  • 6
  • 45
  • 74
4
votes
1 answer

JAXB Marshalling - extending an existing class

I am in need of creating a series of Java objects via XML using JAXB that all extend a common base class that is already created (not using JAXB). For example, let's say I have following JAXB classes that I am trying to generate: Penguin.xml ->…
risingTide
  • 1,754
  • 7
  • 31
  • 60
4
votes
5 answers

Does a derived class object contain a base class object?

Consider the following sample code below: #include using namespace std; class base { public: base() { cout << "ctor in base class\n"; } }; class derived1 : public base { public: derived1() …
nitin_cherian
  • 6,405
  • 21
  • 76
  • 127
4
votes
4 answers

python constructor of derived class

class baseClass(): def __init__(self,mark,name): self.mark = mark self.name = name class derivedClass(baseClass): b1 = derivedClass(name='Jibin') print b1.name This was my code initially & it worked fine. (Note: I don't have access to…
Jibin
  • 3,054
  • 7
  • 36
  • 51