Skip to main content
2 votes
1 answer
94 views

Initializing Base class and member using the same pointer without UB

While reviewing some testing code, I have come across this situation: Suppose we have these two classes: class Project { public: Project(std::string path); ~Project; // [many more ...
perivesta's user avatar
  • 4,138
0 votes
1 answer
95 views

How to replace base class in python [closed]

Here is the code: class A: pass class B: pass class Example(A, B): pass ...a lot of method # new class B called BPlus class BPlus: pass # want a new class Example that base on (A, BPlus) but ...
se7enXF's user avatar
  • 144
-2 votes
4 answers
96 views

How to downcast back a non-generic base-class object to a generic derived-class object at runtime (generic type unknown at compile time) [closed]

I have two classes: a non-generic base class Node and a generic derived class Node<T>. The nodes build a chained list, each node containing eventually a different data type. public class ...
SharpAttempt's user avatar
5 votes
5 answers
188 views

In C#, is inheritance from a method possible?

Now, if the title sounds weird to you, consider this code, I was reviewing today (simplified): public class MyService( IHttpClientFactory httpClientFactory) : BaseService(), // WTF? a ...
Marcel's user avatar
  • 15.8k
0 votes
1 answer
62 views

Circular imports/references between highly-dependent base-class and many sub-classes

Circular imports can drive you mad in Python. Here's one I'm too stupid to solve. I have a base class with lots of functionality, that needs to emit itself, and also all kinds of its sub-classes: # ...
TinyOlap's user avatar
0 votes
1 answer
26 views

How to simply distinguish Base<T> and Base<Int> in Derived<Int> during checking C++ code in clang AST?

I'm checking some C++ code pattern via clang AST and run into a problem. Consider following code: template<typename T> class Base { }; template<typename T> class Derived1 : public Base<...
farta's user avatar
  • 1
0 votes
0 answers
63 views

How do I apply the interface concept with the base-class in design?

I am now studying the concept of OOD and I have created a program for a pizza shop. The base class here is pizza. I want to put a spicy characteristic for pizza as an interface, but I find a problem ...
Oday Allaham's user avatar
0 votes
1 answer
80 views

Serialize derived class from other project throws "The type was not expected. Use the XmlInclude or SoapInclude attribute ..."

Let's say i have two projects in Visual Studio. The Base project and a Derived project. The base project contains a base class: Public Class Car Property Name As String End Class and a generic ...
gegy's user avatar
  • 97
0 votes
0 answers
75 views

Is it possible to provide default implementations of other traits through custom traits?

I have some questions from object oriented design. If I want to define a base class Path, which has two subclasses File and Dir, Path provides the validate method and the from_str method. For some ...
youthlic Ulic's user avatar
-3 votes
3 answers
94 views

does __new__ over ride __init__ in python

I have the following code: class Demo: def __new__(self): self.__init__(self) print("Demo's __new__() invoked") def __init__(self): print("Demo's ...
DCR's user avatar
  • 15.8k
1 vote
0 answers
268 views

How to use the html of the base class in angular

I want to create a base component in my angular app from which other components will extend. I want to use for html, ts and scss a seperate file. In this base component I want to create depending on ...
Stefan's user avatar
  • 41
0 votes
1 answer
92 views

Is it ok to initialize final member in abstract base class using abtract method?

I wonder whether I could initialze a final field in an abstract base class with the result of an abtract method, which would be implemented by the derived class. I understand that derived ctor would ...
Y.F.'s user avatar
  • 69
1 vote
0 answers
64 views

Using a protected inner class as a base class of other class

In the section "11.9 Member access control" of the C++20 Standard there is provided an example (p.#7, example #2) of using a protected inner class of a class as a base class for a derived ...
Vlad from Moscow's user avatar
0 votes
0 answers
273 views

WinForms: Generic forms don't open anymore in designer in .NET 7

In order to be sure that it's .NET 7 (.NET Core) related, I created a project with .NET 4.7.2 with a generic base form and a derived one. Both can be opened and are shown properly. Only in .NET 7 it's ...
IngoB's user avatar
  • 3,027
-1 votes
1 answer
45 views

Including base class variables in the initializer list in the derived class

My project is to create a dive logbook. There is the DiveInfo base class and Equipment derived class. The equipment may change from dive to dive, so obviously it needs to get the variables for ...
kristof's user avatar
  • 19

15 30 50 per page
1
2 3 4 5
46