Category "oop"

LateBinding with dynamic memory

I have Base and Derive class at the below which related to polymorphism (Latebinding) : class Base { .... }; class Derive:public Base { .... }; int main() {

__init__() missing 1 required positional argument it reads self as a parameter

I'm new at programming and I'm learning Python. The code should be very simple. The goal should be implement a calculator that does additions between numbers. I

How can I extend a 3rd party Javascript object using typescript

I've been trying to figure out how to do this most of the after noon, and I'm either not getting something, or I'm approaching things wrong. I'm currently worki

Python circular imports with inheritance

I have a parent and child class, where a parent's method returns an instance of the child. Both classes are in separate files classA.py and classB.py. In order

What is the importance of object oriented programming for competitive programming?

right now i am learning c++ and oop in c++.I usually practice on Codeforces,but i didn't get any use of object oriented programming for solving any problems.So

What does dependency/dependant mean?

http://tutorials.jenkov.com/ood/understanding-dependencies.html#whatis says that (emphasis mine): Whenever a class A uses another class or interface B, then

In Dart, is it possible to pass an argument in a singleton?

class Peoples { late int id; late String name; static final Peoples _inst = Peoples._internal(); Peoples._internal(); factory Peoples() { retur

When are static variables initialized in Python?

Consider the following code class Foo: i = 1 # initialization def __init__(self): self.i += 1 t = Foo() print(t.i) When exactly does the ini

Where is the Balance Between Dependency Injection and Abstraction?

Many Architects and Engineers recommend Dependency Injection and other Inversion of Control patterns as a way to improve the testability of your code. There's n

Convert UDT subtype to supertype

I use a user-defined type (UDT) in Oracle 18c called ST_GEOMETRY: The ST_Geometry storage type ST_Geometry in Oracle SQL functions used with ST_Geometry I have

Friend function inside class and outside class, what difference does it make?

#include<iostream.h> #include<conio.h> class time { private: int dd,mm,yy; public: friend istream & operator >>(is

Copy child object to parent object

I have three classes: Shape, Rectangle and Circle. Shape is parent of two other class. definition of this classes is in following code: #include <iostream>

Initiate single instance from a constructor and use it as static method in another class

I have a class of utilities that I use all over my app it contains a method to format numbers class Utils { static numberFormater () { return new I

A Swift protocol requirement that can only be satisfied by using a final class

I'm modeling a owner/ownee scheme on Swift: class Owner<T: Ownee> { // ... } protocol Ownee { var owner: Owner<Self> { get } } Then I h

can anyone explain what "out = self(images)" do in below code

I am not able to understand, if prediction is calculated in forward method, then why there is need "out = self(images)" and what it will do. I am bit confuse ab

Pass Parameter to Base Class Constructor while creating Derived class Object

Consider two classes A and B class A { public: A(int); ~A(); }; class B : public A { public: B(int); ~B(); }; int main() { A* aobj; B

How to programmatically find public properties of a class from inside one of it's methods

I've got a class Foo with public and protected properties. Foo needs to have a non-static method, getPublicVars() that returns a list of all the public propert

Can casts be completely avoided with a good design?

I'm wondering whether situation exists where casting is completely necessary. I'm talking here about casts between classes, not basic types. Is casting (be it

Why does a static constructor not have any parameters?

Per MSDN: A static constructor does not take access modifiers or have parameters. A static constructor is called automatically to initialize the class before t

What is the exact difference between Adapter and Proxy patterns?

As I understood both Adapter and Proxy patterns make two distinct/different classes/objects compatible with each for communication. And both of them are Structu