what is the size of an abstract class and why can't we create objects of an abstract class?
what is the size of an abstract class and why can't we create objects of an abstract class? ...
what is the size of an abstract class and why can't we create objects of an abstract class? ...
I am writing a BFS and DFS in Java. What I was hoping to do was create one class like this: /** Preforms BFS and DFS on ... */ public class Search{ private XXX toSearch; // where XXX is an interface of Stack and LinkedList that has // remove() and add() methods. public Search(boolean isBFS){ if(isBFS) toSearch = ...
Hello, I have a problem naming the elements in my application's data model. In the application, the user has the possibility to create his own metamodel. He does so by creating entity types and a type defines which properties an entity has. However, there are three kinds of entity types: There is always exactly one instance of the ty...
I've got two classes : Unit and User. a Unit class has a User as leader, and a User can be part of many units. class Unit { User Leader; public void SetLeader(User leader) { this.Leader=leader; } } class User { Unit UnitLed; public void LeadUnit(Unit unit) { this.UnitLed=unit; unit.SetLeader(this...
I want to get all non static class vars from a class. The problem I have is in the "Non static" part. The following: foreach(array_keys(get_class_vars(get_called_class())) AS $key) { echo $key; } How can I find out $key is a static property or a non static. I know I could try something like: @$this->$key But there must be a bet...
I have a piece of code, that moves an array depending on it's type. If the array is of TypeA objects, it will change TypeA. If it is TypeB it will change TypeB. The issue with the current code is the repeative blocks. private function scrollRight():void { if (SELECTED == CONSTANT) { if (_avatarDat...
I am starting to use decorators in PHP more often these days to modify an object's behavior at run-time. My problem is primarily one of laziness, we have many legacy classes with tons of methods and the thought of having to re-write/override all of them for each decorator class makes me sad. Does anyone know of a command line utility t...
I have instances of Item that I would like to have in groups ItemGroup. But if an Item is moved to another itemgroup, I would like to keep track of the change for accountability reasons. E.g. I need to know if an Item was in one ItemGroup in October and another in September. How should I model this in the database? How should I model th...
a = Numeric.new # doesn't take an argument I can't imagine a use case for this. Can you? ...
I have a class like the following: class DreamsImagesStore { public $table = 'dreams_images'; public function insertNewDreamImage($dream_id, $pid) { try { $values = array($dream_id, $pid); $sth = $this->dbh->prepare("INSERT INTO {$this->table} (dream_id, pid) ...
What is the most interesting or difficult question asked to you during an C++/OOD interview? What is the most interesting or difficult question you like to ask to a candidate during a C++/OOD interview? Edit: Updated the misleading Title Edit: Ofcourse: 1. When you are the one being interviewed. 2. When you are intervieweing so...
Will be nice if I got 'nested members' in D language, so I have the inglorious idea to code class Keyboard { struct Unused { string key1 = "Wake Up"; string key2 = "Sleep"; string key3 = "Power"; } Unused unused; } int main() { Keyboard kb; kb.unused.key1 = "Scroll Lock"; return 0; } ...
How can I access an extended Class function from an already created object? (A) - This works, by not creating an object: $UserType = 'User_Vote'; $vote = User::getVote($UserType)->getVoteQuery(); (B) - Trying the same idea from an already created object (this is what I want to do) returns the error: unexpected T_PAAMAYIM_NEKUDOTAYIM ...
I am looking for few examples of class extension without Lyskov Substitution Principle violation, where class being extended is not a template/abstract/skeleton class, and extending class isn't just a decorator. ...
In .NET, integer data type is a value type(stack) and String is a reference type(heap). So If a class A has an integer, and a string type object in it, and a class B creates an object of class A, then how will this object of class A be stored in memory? In stack, or in a heap? This was asked in my Microsoft interview. Need to understan...
We use USPS API for international shipping. The API returns a shipping cost and we add % Handling charge. We want to set a minimum charge, e.g., if shipping + handling is less than $5 we want to set the shipping price to $5. Would this require writing a full shipping module or just adapt the USPS module? ...
So if I create an object test, and it has a property color. When I add this object to an array list I typically can access this using myarray(0).color but intellisense doesn't 'know' that I have a 'test' object inside the array. It would let me type myarray(0).whatever but would then crash if I made typo. It seems like I should be able t...
I'm writing a simulation in Python for a dice game, and am trying to find the best way to handle the following situation in an Object Oriented manner. I have a Dice class that handles rolling the dice and reporting things about the dice. This class's methods include a roll() method which modifies the dice values, and various reporting ...
Wondering if there's any accepted practice for approximating C++'s 'const methods' in Objective-C. (new to the language from a C/C++ background) For instance: class Foo { public: void canChangeMemberVars(void); char* asString(void) const; }; "asString()" gets a const this pointer, so even if you go rogue and decide to mu...
Here is my issue. I'm creating my own GUI Api. All the Widgets are in a container which has add and remove functions. The widgets derive from a base widget class. Here is where I'm unsure. I would ideally like a flow like this: user creates a (desired widget deriving from base class) pointer, the container allocates and manages resources...