base-class Questions

5

Solved

Now, if the title sounds weird to you, consider this code, I was reviewing today (simplified): public class MyService( IHttpClientFactory httpClientFactory) : BaseService(), // WTF? a Method? I...
Neutron asked 20/8, 2024 at 7:27

5

Solved

We have a package that we are looking to convert to kotlin from python in order to then be able to migrate systems using that package. Within the package there are a set of classes that are all va...
Expressman asked 31/10, 2017 at 6:39

42

Solved

This question is not for the discussion of whether or not the singleton design pattern is desirable, is an anti-pattern, or for any religious wars, but to discuss how this pattern is best implement...
Pap asked 20/7, 2011 at 10:47

33

Solved

Is it possible to assign a base class object to a derived class reference with an explicit typecast in C#?. I have tried it and it creates a run-time error.
Mikkimiko asked 8/4, 2009 at 11:12

2

Solved

I have a type trait and concept which checks if an std::variant can hold a given type T. Now I have a type variant2 which derives from std::variant, and I want to use that type trait with the new v...
Kayne asked 12/6, 2023 at 14:47

4

Solved

Is it possible to make a C# base class accessible only within the library assembly it's compiled into, while making other subclasses that inherit from it public? For example: using System.IO; cl...
Gallbladder asked 1/6, 2012 at 22:31

5

Solved

Because of this issue here, I'm trying to write a custom JsonConverter that handles cases where you subclass a list or a collection, then add extra properties to it. As such, one approach would be ...
Spokesman asked 4/5, 2011 at 8:45

8

Solved

I have a situation, where two classes (one deriving from the other) both implement the same interface explicitly: interface I { int M(); } class A : I { int I.M() { return 1; } } class B : A, ...
Jocularity asked 12/5, 2011 at 9:50

5

Solved

In a base class for all the models in our MVC system, I created a factory method BaseCLass::getNew() that returns an instance of the requested child class when called via SomeChildClass::getNew(). ...
Significs asked 27/3, 2011 at 2:31

7

Solved

class Person { public int age; public Person() { age = 1; } } class Customer : Person { public Customer() { age += 1; } } Customer customer = new Customer(); Would the age of customer ...
Concession asked 31/10, 2012 at 19:16

3

Solved

I searched for a while for this one and was surprised i couldn't find anything, maybe because it's simple. I've been programming in python for about 3 months doing automated testing with selenium w...
Ramey asked 2/6, 2014 at 18:58

3

I'm trying to write a custom JsonConverter for cases where a person subclasses a list or collection, but then adds extra properties to the subclass (see here). The current implementation of JSON.NE...
Stravinsky asked 4/5, 2011 at 9:3

7

Solved

I have a base class Person and derived classes Manager and Employee. Now, what I would like to know is the object created is Manager or the Employee. The person is given as belows: from Project.C...
Diffusive asked 10/7, 2012 at 6:59

5

Solved

I was under impression that it's impossible, see for example: Calling the constructor of the base class after some other instructions in C++ But the following program runs and produces two lines o...
Irritable asked 28/1, 2014 at 1:52

10

Solved

I've seen a lot of people talk about using base controllers in their ASP.NET MVC projects. The typical examples I've seen do this for logging or maybe CRUD scaffolding. What are some other good use...
Cacia asked 25/5, 2011 at 3:25

9

Solved

I need to extend the Networkx python package and add a few methods to the Graph class for my particular need The way I thought about doing this is simplying deriving a new class say NewGraph, and ...
Outsmart asked 12/8, 2010 at 1:20

2

Solved

Python seems to lacks a base class for "all numbers", e. g. int, float, complex, long (in Python2). This is unfortunate and a bit inconvenient to me. I'm writing a function for matching data types...
Rate asked 26/6, 2017 at 9:14

3

Solved

I understand why this is happening, but I'm stuck trying to resolve it...here is what my code is doing when the error is generated (thus, leading to a crash) when my program exits... pure virtual ...
Alleviate asked 22/5, 2012 at 17:49

2

Solved

Based on the other posts I have read, it seems that this may not be possible, but I thought I would post what I am trying to do and see if anyone knows of a solution. I am trying to add a "Clone(...
Peddler asked 20/8, 2015 at 15:42

2

Solved

I have a Visual Studio 2010 Windows Forms app which includes a Form base class that other classes will inherit. The base class' constructor takes a parameter that the child classes will pass to the...

2

Solved

I am reading book "C# 4.0 in a nutshell" by Joseph Albabari and Ben Albabari. From there I find a topic restrictions on access modifiers. Page 91, Topic "Restrictions on Access Modifiers". Quoting...
Liddle asked 20/5, 2013 at 12:47

2

Solved

Summary How can I create a base class that extends PHPUnit_Framework_TestCase and use that for subclassing actual test cases, without having the base class itself tested by PHPUnit? Further expla...
Marchioness asked 23/2, 2012 at 21:29

9

I have a class (TabControlH60) that both inherits from a base class (UserControl) and implements an interface (IFrameworkClient). I instantiate the object using the .NET Activator class. With the r...
Cariole asked 20/10, 2009 at 19:25

3

I am trying to implement good design patterns for a program I am writing. I have a class structure like this. abstract class SomeBase { public SomeObject obj { get; protected set; } protected S...
Tamayo asked 18/9, 2014 at 17:34

2

Solved

In C#, as shown in the code snippet below, is it correct/proper to extend the interface IFoo when declaring the class A, knowing that the class BaseClass extends the interface IFoo? Is it necessary...

© 2022 - 2025 — McMap. All rights reserved.