Hi Folks,
I've been wondering:
Using prototypes in JavaScript should be more memory efficient than attaching every member of an object directly to it for the following reasons:
The prototype is just one single object.
The instances hold only references to their prototype.
Versus:
Every instance holds a copy of all the members and...
hi
consider we have 2 data entry win forms : form1 (parent) and form 2 child of that parent.
As all we know, we can simply declare virtual methods in order to be overridden by any child
in future.
my question is how to construct blueprint of the parent form methods? I mean every method should be virtual? or what?
Thank you
...
I would like to get the stackoverflow community's opinion on the following three design patterns. The first is implementation inheritance; the second is interface inheritance; the third is a middle ground. My specific question is: Which is best?
implementation inheritance:
class Base {
X x() const = 0;
void UpdateX(A a) { y_ = g(...
I hope this code explains the problem:
class Foo {
void a() { / *stuff */ }
}
class Bar extends Foo {
void a() { throw new Exception("This is not allowed for Bar"); }
class Baz {
void blah() {
// how to access Foo.a from here?
}
}
}
I know that I may be doing something wrong, because inher...
Hello all
I have created a dll that will be used by multiple applications, and have created an installer package that installs it to the program files, as well as adds it to the Global Assembly Cache.
The dll itself uses log4net, and requires a xml file for the logging definitions.
Therefore when the installer is run, the following fi...
Possible Duplicates:
C++ method only visible when object cast to base class?!
Why does an overridden function in the derived class hide other overloads of the base class?
#include <iostream>
using namespace std;
class A
{
public:
virtual void foo(void) const { cout << "A::foo(void)" << endl; }
virtual void foo(int ...
I have problems with saving derived type (TPT) with Entity Framework to database.
Let's say I have base entity Animal and derived type Dog.
I want to save Dog entity.
I thought that I could do it like contex.AddToDogs(), but contex contain only base entity - Animal. So I can only save Animal object - contex.AddToAnimals().
I have als...
Hey,
I'm experiencing some problems with breaking my code to reusable parts using templates and inheritance. I'd like to achieve that my tree class and avltree class use the same node class and that avltree class inherits some methods from the tree class and adds some specific ones. So I came up with the code below. Compiler throws an e...
VB.NET 2008 .NET 3.5
I have two base classes that are MustInherit (partial). Let's call one class OrderBase and the other OrderItemBase.
A specific type of order and order item would inherit from these classes. Let's call these WebOrder (inherits from OrderBase) and WebOrderItem (inherits from OrderItemBase).
Now, in the grand sche...
Sorry the question wasn't properly stated by me earlier. I try to implent the Factory Pattern. A better example: It is an abstract class Human with a function create. Based on the arguments that is passed to create it decides whether to return an instance of its subclass Man or an instance of subclass Woman. So you call create with:
Hum...
I strongly believe that, reading code and reading good code is key to great programming. If not one of the many.
I had been facing some problems in visualizing and having a "feel" of using inheritance to better my code architecture.
Can somebody give me some link to good code to emulate, where folks have used inheritance in an absolute...
Hi,
My question is about defining an XML schema that will validate the following sample XML:
<rules>
<other>...</other>
<bool>...</bool>
<other>...</other>
<string>...</string>
<other>...</other>
</rules>
The order of the child nodes does not matter. The cardinality of the child nodes is 0..unbounded.
All the chi...
I have a code snippet like this
class A(object):
class b:
def print_hello(self):
print "Hello world"
b = property(b)
And I want to override the inner class b (please dont worry about the lowercase name) behaviour. Say, I want to add a new method or I want to change an existing method, like:
class C(A):
...
Hi!
Basically, I have an ImageMetadata class and an Image class, which derives from ImageMetadata. Image adds one property: byte[] Content, which actually contains binary data.
What I want to do is to map these two classes onto one table, but I absolutely do not need NHibernates' inheritance support to kick in. I want to tailor FNH Aut...
To track revisions of a Page class, I have a PageRevision class which inherits from Page and adds a revision ID (Guid RevisionID;).
If possible, how should I cast an existing Page object to a PageRevision and ensure that the PageRevision constructor is called to create a new revision ID?
I could could have a PageRevision(Page page) con...
I'm drawing polygons using the Graphics View framework. I added a polygon to the scene with this:
QGraphicsPolygonItem *poly = scene->addPolygon(QPolygonF(vector_of_QPointF));
poly->setPos(some_point);
But I need to implement some custom behaviour like selection, mouse over indicator, and other similar stuff on the graphics item. So I...
I have a property in a base class tagged with attributes, and I would like to change some of the attributes in each of my derived classes. What is the best way to do this?
From what I can tell, I have to define the property as abstract in my base class and override the property in each of my base class, and redefine all of the attribut...
I have the following classes:
Defect - represents a type of data that can be found in a database
FilterQuery - provides a way of querying the database by setting simple Boolean filters
Both Defect and FilterQuery implement the same interface: IDefectProperties. This interface specifies particular fields that are in the database. D...
Suppose a Table per subclass inheritance relationship which can be described bellow (From wikibooks.org - see here)
Notice Parent class is not abstract
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Project {
@Id
private long id;
// Other properties
}
@Entity
@Table(name="LARGEPROJECT")
public class ...
Suppose I have a class Dog that inherits from a class Animal. What is the difference between these two lines of code?
Animal *a = new Dog();
Dog *d = new Dog();
In one, the pointer is for the base class, and in the other, the pointer is for the derived class. But when would this distinction become important? For polymorphism, ...