Tagged Questions
2
votes
1answer
43 views
In Swift, how can you traverse the class inheritance of an object?
I'm getting an object back from a method, and it is of a class I don't know, but I'd like to know what the superclasses are. Is there a way to do that?
0
votes
3answers
55 views
How to write an abstract class as an interface
I've googled extensively for an answer to this question, but I either do not know what the technical term is, or else it's not possible, so forgive any ignorance on my part, please.
First the code, ...
0
votes
0answers
36 views
Object has no attribute 'lower'
I'm working on a problem set from the MIT OpenCourseWare course (with no credit whatsoever) and came across this problem. I'm trying to create an RSS Feed filter.
I first created an object that ...
-3
votes
1answer
59 views
Python Classes - No calls? One Loop?
I have recently started using classes and have two questions.
I know that like a function, python has to read through all class lines once before any calls are made or initiated.
>
EDIT>>>So I ...
0
votes
1answer
28 views
Trouble understanding python inheritance arguments
I've tried reading a few different tutorials, but I still can't figure it out. I have two simple classes. Animal and cat.
class Animal:
def __init__(self, name):
self.name = name
class ...
1
vote
1answer
33 views
Python Inheritance with closures
How do I accomplish this kind of inheritance if I have to override or inherit the function2 from class A in class B?
class A(object):
def function1(self, x, y):
def function2(y):
...
2
votes
2answers
61 views
Use Java methods in multiple classes
I know this question has been asked a million times, but I can't find a decent answer.
I have a bunch of messenger methods like debug(String) and tell(CommandSender, String) that I want to use a ...
11
votes
9answers
276 views
Interview Puzzle - Multiple Inheritance in Java?
I just had an interview, and I was asked a question.
Interviewer - Does java support multiple inheritance ?
Me - No
Interviewer - Each class in java extends class Object (except class Object) and ...
0
votes
2answers
49 views
Super class constructor getting sub class name as a string
Here's one. I have a base class for all my exceptions. The base class retrieves a message from app.config which is based on the class name. So if I have 10 exceptions I have 10 messages in app.config.
...
0
votes
2answers
22 views
PHP Namespace Class
I read up quite a bit on namespaces in PHP and I'm still confused.
I have a class in a different folder that is under the namespace Entity (Class A).
I have another class in a different folder that ...
-5
votes
3answers
47 views
C++ abstract class static methods showing in derived classes
I'm coming from a C# background and now trying to pick up C++. I'm using an abstract class that has a static member to keep track of the total number of that object type, and a static method to get ...
-2
votes
1answer
23 views
missing derived class with QObject
I am getting the error ~mainwindow.cpp:9: error: redefinition of 'MainWindow::MainWindow(QWidget*)' MainWindow::MainWindow(QWidget *parent) : and I am pretty sure it is complaining about the wrong ...
0
votes
2answers
22 views
Instantiate subclass from mother class intelligently
Let's say I have a motheclass (abstract or not) Item and two subclasses ItemA et ItemB which both inherit from Item
All instances are created based on a NSDictionary through the following method
...
-1
votes
1answer
22 views
PHP Class linking
I have an issue with classes and childs.
Right now I have it like this (my Core class)
https://gist.github.com/anonymous/8fb344e9743284a5b12b
Note line 37-41. Those classes are extending core.
Now ...
2
votes
1answer
32 views
Inheritance tree in android programming
I have been introduced to android programming recently and it is a new experience for me.
Well I was looking for some graphical representations of inheritance classes in android. Below is a simple ...
-3
votes
1answer
52 views
How to call a function in all inheritant classes? [closed]
For example let's say I have this class:
class base{
public:
update();
};
and I have a lot of classes that are inherit from this one:
class A : public base
{
//<...>
}
class B : ...
0
votes
1answer
11 views
getting value from a class that instantiated current class
I am really sorry if this is s dumb question and I'm having a brain fart, this just seems like something I should know. If I have a structure similar to below, is there some way to get $fooVar in ...
0
votes
1answer
36 views
Python inherited base class variables
So I have Base class with two Child classes. The idea was that I would have a model containing all data which I could plug into one of the child classes. Then call a method to set the headers on each ...
4
votes
7answers
59 views
Implement interface by inherited Class in Java
I have interface Car:
public interface Car {
pubilc void run();
}
Also i have a base class that implements this interface:
public class Base implements Car {
@Override
public void ...
0
votes
3answers
27 views
PostActive visibility of class methods
I have here this abstract base class called base_class defined as it follows:
class base_class
{
public:
virtual ~base_class() = 0 {}
virtual size_t area() const = 0;
protected:
...
160
votes
20answers
15k views
Use of .apply() with 'new' operator. Is this possible?
In JavaScript, I want to create an object instance (via the new operator), but pass an arbitrary number of arguments to the constructor. Is this possible?
What I want to do is something like this ...
2
votes
2answers
108 views
Which comes first in Ruby the Class or the BasicObject?
At first glance I thought BasicObject just "lays" the Class (read: Class inherits from BasicObject)
Class.ancestors #=> [Class, Module, Object, Kernel, BasicObject]
Module.ancestors #=> ...
0
votes
2answers
60 views
C++ Class Inheritance Order
This is similar to other questions I'm sure, I read through. I am trying to write a move class. I need a Player class and an Item class that inherits the move class, or vice versa. That is what I am ...
-1
votes
1answer
29 views
How to bring a nested class to inherit?
I'm trying to initialize an inheriting class inside another class, but it doesn't work and I don't know how to solve.
I've read here that inheriting generally works following way:
class Foo(object):
...
0
votes
4answers
373 views
Link Error C++ Inheritance
I have two classes Person and Student. I'm currently trying to derive the Student class from the Person Class.
However, I keep getting a link error.
The error:
[Linker error] undefined reference to ...
9
votes
2answers
5k views
How can I dynamically create derived classes from a base class
For example I have a base class as follows:
class BaseClass(object):
def __init__(self, classtype):
self._type = classtype
From this class I derive several other classes, e.g.
class ...
0
votes
2answers
25 views
C# - import class from third-party library and make it a derived class (or something similar)
I'm a beginner in C#. I would like to import a class from a third-party library and make it a derived class (or something similar). In the following example, how can I create a class that can have ...
0
votes
2answers
55 views
Is the Visual Inheritance in C# (Framework 4.0) similar to visual inheritance in VFP?
In VFP I can create a class (gridclass1) with a grid, then I create a form where use this class (gridclass1) and can modify their properties in the instance. And Then I can create another class ...
0
votes
2answers
36 views
Basic Inheritance in Python?
I'm trying to teach myself inheritance using a simple example in Python but I can't seem to grasp the basics. I'm trying to use the add function defined in the MathOps class and use it in the ...
0
votes
3answers
37 views
Convention for inheritance from class instance to add details/functionallity
I have a class called Image
class Image(object):
def __init__(self,rgb_img):
self.img_time = time.time()
self.img_colr = rgb_img
I want to store some more information on this ...
4
votes
8answers
25k views
Class extending more than one class Java?
I know that a class can implement more than one interface, but is it possible to extend more than one class? For example I want my class to extend both TransformGroup and a class I created. Is this ...
2
votes
4answers
2k views
python class attribute inheritance
I am trying to save myself a bit of typing by writing the following code, but it seems I can't do this:
class lgrAdminObject(admin.ModelAdmin):
fields = ["title","owner"]
list_display = ...
0
votes
1answer
27 views
Ruby inherit specific methods
I have this problem. I want to make a class which inherits from Array. Then I can just do this
class MyClass < Array
However, I only want to inherit a number of methods , not all of them, so my ...
0
votes
1answer
88 views
C++ pure virtual method defined at run-time
Not sure if the name is very telling but here goes.
I am interfacing to an API that requires a base class to be inherited and a lot of pure virtual methods to be defined.
For good programming ...
7
votes
7answers
2k views
Confusing JavaScript statement: “var x = new this();”
I thought I understood the concept of the JavaScript prototype object, as well as [[proto]] until I saw a few posts regarding class inheritance.
Firstly, "JavaScript OOP - the smart way" at ...
3
votes
2answers
82 views
Is it possible to override a base method with a more specific (by return type) method?
I have classes like this.
public class Base{
public virtual Base Clone(){ ...... }
}
public class Derived:Base{
public Derived Clone(){ ...... }
private override Base Clone(){ return ...
0
votes
1answer
77 views
Understanding good habits with OOP and multiple inheritance in C++
I have recently learnt that I haven't been practicing the best habits in OOP and have begun studying better habits for OOP. So my question is this - should I limit how many things a class inherits to ...
22
votes
9answers
9k views
C++: Can a struct inherit from a class?
I am looking at the implementation of an API that I am using.
I noticed that a struct is inheriting from a class and I paused to ponder on it...
First, I didn't see in the C++ manual I studied ...
1
vote
1answer
25 views
RequireJS and Class Inheritance
I'm trying to implement classical inheritance in Javascript using RequireJS modules to build a game engine using HTML5. I've tried using John Resig's Class.js but it doesn't seem to be work the way I ...
3
votes
7answers
121 views
OOP: understanding Abstraction
i have gone through many articles and some stackoverflow questions for better understanding of abstraction but there is a confusion , for example this is what i read it here
Abstraction is ...
1
vote
4answers
19 views
PHP Methods Referencing Each Other causes PHP to return “No Data”
PHP Methods Referencing Each Other causes PHP to return a page that says "No data received"
I am completly lost as to why this is happening since both methods belong to the same class...help please? ...
-1
votes
1answer
64 views
Best practice for using derived class in C++ [closed]
I have a Base class:
class Base{
public:
int id;
virtual void method();
bool identify(int _id);
...
}
and some derived classes:
class d1:public Base{
public:
int id;
void ...
0
votes
1answer
55 views
Class inheritance and friendship project
I stumbled across what seems to me a very interesting problem. I am not asking for a solution to this problem, only advices on how to continue with my code and I'd like to know if derived classes ...
0
votes
0answers
10 views
Extending pymc Multinomial class
I am unable to figure out how to create a class that has all the members of pymc.Multinomial class except that I want to redefine logp sine I don't want to get -inf while calculaing log(0)
I realize ...
2
votes
1answer
29 views
Why I can't make separated table copies in Lua?
In a file I do a code like this:
Source = {}
Source[1] = { a = 1, b = 2, ... }
in another file, I do the next:
Table = {}
Table[1] = Source[1]
Table[2] = Source[1]
I use this method for creating ...
2
votes
1answer
22 views
Do I need to split a large DTO?
I have a DTO with 30 attributes, some attributes would be added to it.
Many other classes use this DTO, some classes use 10 to 20 attributes, some other class uses all 30 attributes.
In one class, ...
-1
votes
3answers
40 views
Unexpected behavior of derived class using parent class member to call overridden member
I have a class derived from a parent class. It calls a member from the parent class. However a behaviour of the member need to be revised due to the functional requirement of the child class. I wrote ...
112
votes
7answers
122k views
Call a parent class's method from child class in Python?
When creating a simple object hierarchy in Python, I'd like to be able to invoke methods of the parent class from a derived class. In Perl and Java, there is a keyword for this (super). In Perl, I ...
0
votes
1answer
506 views
How is it possible the class inheritance in namespaces using Ruby on Rails 3?
In my RoR3 application I have a namespace called NS1 so that I have this filesystem structure:
ROOT_RAILS/controllers/
ROOT_RAILS/controllers/application_controller.rb
ROOT_RAILS/controllers/ns/
...
-1
votes
1answer
35 views
In Java, can a subclass replace an attribute with that attribute's subclass?
Doing something like this:
class Foo {
Foo foo;
...
}
class Bar extends Foo {
...
}
class Baz extends Foo {
Bar foo;
...
}
works, but I'm not sure if in class Baz, Bar foo ...