oop Questions

2

Solved

I had namedtuple variable which represents version of application (its number and type). But i want and some restriction to values: Version = namedtuple("Version", ["app_type", "number"]) version ...
Spectrogram asked 26/6, 2019 at 19:43

2

Solved

Is it okay to use const_cast in the following case, or are there any caveats: class A { public: A() : m_someData(5) {} int& get() { return m_someData; } const int& get() const { return...
Dexamethasone asked 17/3, 2014 at 8:58

6

Solved

What is the purpose of checking self.__class__ ? I've found some code that creates an abstract interface class and then checks whether its self.__class__ is itself, e.g. class abstract1 (object): ...
Lassa asked 15/12, 2013 at 20:27

9

Solved

I'm learning C# and a thought came up when coding. Is it possible to automaticly store parameters from a constructor to the fields in a simple way without having to write this.var = var on every va...
Arista asked 22/2, 2019 at 10:14

3

A derived class can call a protected base class constructor in its ctor-initializer, but only for its own base class subobject, and not elsewhere: class Base { protected: Base() {} }; class Der...
Faze asked 8/7, 2014 at 15:47

4

Solved

Definitions taken from here Dependency Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the sa...
Rolfe asked 9/1, 2014 at 13:47

15

Solved

What is the difference between cohesion and coupling? How can coupling and cohesion lead to either good or poor software design? What are some examples that outline the difference between the two...
Lida asked 21/6, 2010 at 14:1

20

I know that Python does not support method overloading, but I've run into a problem that I can't seem to solve in a nice Pythonic way. I am making a game where a character needs to shoot a variety ...
Roaster asked 22/6, 2011 at 3:11

6

Solved

In Javascript, I would like to define a class with an inner (or nested) class. Within the inner class I'd like to be able to get access to the parent instance. How can I do this efficiently? Some...
Archivolt asked 22/1, 2011 at 15:10

10

Solved

There is a possible optimization I could apply to one of my methods, if I can determine that another method in the same class is not overridden. It is only a slight optimization, so reflection is o...
Subtreasury asked 23/2, 2010 at 0:57

11

Solved

I have gone through most of the documentation of __getitem__() in the Python docs, but I am still unable to grasp the meaning of it. So all I can understand is that __getitem__() is used to impleme...
Chasse asked 26/4, 2017 at 7:15

2

Solved

Whenever you extend a class in JavaScript or Python, the derived class must use the super keyword in order to set attributes and/or invoke methods and constructor in the base class. For example: cl...
Ibo asked 5/7, 2023 at 22:43

1

Solved

I know that std::unique_ptr doesn't guarantee memory safety and especially it is true in the case of circular dependency. However, in my case, I can't see it. Child contain Parent(or SecondChild in...
Phraseograph asked 2/7, 2023 at 20:57

4

Solved

I have some object, say son, which I'd like to inherit from another object father. Of course I can make a constructor function for father, like Father = function() { this.firstProperty = someVal...
Neopythagoreanism asked 10/8, 2010 at 18:57

4

Solved

In traditional object-oriented languages (e.g. Java), it is possible to "extend" the functionality of a method in an inherited class by calling the original method from the super class in the overr...
Uchish asked 16/7, 2015 at 18:31

7

Solved

I'm trying to achieve some basic OOP in JavaScript with the prototype way of inheritance. However, I find no way to inherit static members (methods) from the base class. We can simulate the basic ...
Vitkun asked 26/3, 2011 at 9:39

5

Solved

I have a code like that: User = function(){} User.a = function(){ return "try"; } User.b = function(){ } ​ From User.b() I can call User.a() using: User.b = function(){ return User.a(); ...
Dimmick asked 28/6, 2012 at 16:30

7

Solved

Can I declare a method in an object as both a static and non-static method with the same name that calls the static method? I want to create a class that has a static method "send" and a non-stati...
Sorbitol asked 4/7, 2012 at 15:5

42

Solved

Can someone provide a simple explanation of methods vs. functions in OOP context?
Intertwine asked 30/9, 2008 at 23:45

24

Solved

In PHP 5, what is the difference between using self and $this? When is each appropriate?
Selby asked 30/9, 2008 at 6:23

8

Solved

How can you construct objects passing arguments directly to your own classes? Something like this: Dim this_employee as Employee Set this_employee = new Employee(name:="Johnny", age:=69) Not be...
Lenee asked 5/3, 2013 at 12:43

5

Solved

I have a basic question in Java, but it's a general question in OOP. Why do interfaces allow fields to be set? Doesn't that run contrary to what an interface is supposed to do? The way I made sen...
Prescience asked 25/2, 2012 at 18:40

14

Solved

I was wondering how to check whether a variable is a class (not an instance!) or not. I've tried to use the function isinstance(object, class_or_type_or_tuple) to do this, but I don't know what typ...
Mckale asked 28/12, 2008 at 3:8

5

according to http://www.cs.cornell.edu/courses/cs211/2006sp/Lectures/L08-abstraction/08_abstraction.html abstraction comes in two flavors. One is function abstraction and the other is data abstrac...
oop
Pilgarlic asked 26/9, 2012 at 2:51

18

Solved

I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a fo...
Lontson asked 23/9, 2008 at 22:32

© 2022 - 2024 — McMap. All rights reserved.