Consider the following where class "Circle" inherits from "Shape":
dim objListOfCircles as new List(of Circle)
DrawShapes(objListOfCirlces)
Private sub DrawShapes(byref objListOfShapes as List(of Shape))
for each objShape as Shape in objListOfShapes
objShape.Draw()
next
end sub
I can't get this to work. What is the explainati...
I installed 'Thank you plugin' but the button on my test site but the button looks strange.
I found why. Because it inherits #commentform textarea { width: 45%;} from my theme. If I remove the width from css the button looks ok. Any idea how I can fix that? Of course I do not want to remove width for #commentform textarea. Can I do some...
I have the following code which is seems to be lead to the infinite loop:
struct X
{
void my_func( int ) { std::cout << "Converted to int" << std::endl; }
};
struct X2 : X
{
void my_func( char value ) { my_func(value); }
};
What is the problem with it?
...
Hi guys,
I am trying to add shared members in derived classes and use that values in base classes...
I have base
class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
....
end function
end class
my derived class
class Us...
I have a class, Autodrop, that contains several methods , a.o. 'metadata', that call an external API (dropbox). They are slow.
However, I already often have that metadata around when initializing the AutodropImage, so I should make the methods smarter.
What I have in mind is this:
class Autodrop
include Dropbox
attr_reader :path
...
Why C++ compiler gives this error? Why i can access lol() from B, but can not access rofl() [without parameters]. Where is the catch?
class A
{
public:
void lol(void) {}
void rofl(void) { return rofl(0);}
virtual void rofl(int x) {}
};
class B : public A
{
public:
virtual void rofl(int x) {}
};
int _tmain(int argc, _TCHAR*...
When i try to create good object hierarchy which will help to write less code and avoid to use unnecessary fields ,i feel myself free to create many base classes for good grouping which is usually abstract.
What can be disadvantage of doing it like that ? Many times inherited class can be slower ?
To see many unnecessary abstract classe...
Hello
When creating inheritance hierarchy, i get confused .Abstract Base class should contain only commonly used stuffs for inherited classes.But knowing which is commonly used methods,fields and properties is not possible while designing.So i feel free myself to grouping them with abstract classes which inherits hierarchicaly. This is ...
I have a entities as:
BaseEntity --> Which contains user login info like createdBy, createdTime, EditedBy, editedTime
Employee --> which contains employee information like name, address, etc...
RegularEmployee --> which contains salary, bonus tht kind of fields
and
ContactEmployee --> which contains HourlyRate, contactPeriod etc....
...
I'm creating a custom Layout for android.
The layout implementation is exactly the same, but once I need to extend from RelativeLayout, and once from LinearLayout.
class Layout1 extends LinearLayout {
// methods and fields
}
class Layout2 extends RelativeLayout {
// the same EXACT methods and fields
}
How can I use inheritance to avo...
I'm trying to understand whay i get an error on this code:
(the error is under g++ unix compiler. VS is compiling OK)
template<class T> class A {
public:
T t;
public:
A(const T& t1) : t(t1) {}
virtual void Print() const { cout<<*this<<endl;}
friend ostream& operator<<(ostream& out, const A<T>& a) {
out<<"I'm ...
If a Father is a Parent and a Parent is a Person and a Person has a Father I create the following:
class Person{
Father father;
}
class Parent extends Person{}
class Father extends Parent{}
Instances:
Person p1 = new Person();
Person p2 = new Person();
p1.father = p2; //father is of the type Father
This doesn't work... Now tr...
Hello!
I have a few classes (heat, gas, contact, pressure) inheriting from a main one (sensor).
I have a need to store them in a vector<Sensor *> (part of the specification).
At some point in time, I need to call a function that indiscriminately stores those Sensor *. (also part of the specification, not open for discussion)
Somethi...
I want to define a base class that defines a main method that instantiates the class, and runs a method. There are a couple of problems though. Here is the base class:
public abstract class Strategy
{
abstract void execute(SoccerRobot robot);
public static void main(String args)
{
Strategy s = new /*Not sure what to...
Have a quick question about what would be the best way to implement iterators in the following:
Say I have a templated base class 'List' and two subclasses "ListImpl1" and "ListImpl2". The basic requirement of the base class is to be iterable i.e. I can do:
for(List<T>::iterator it = list->begin(); it != list->end(); it++){
...
}
...
Hi all! I am trying to define a javascript class with an array property, and its subclass. The problem is that all instances of the subclass somehow "share" the array property:
// class Test
function Test() {
this.array = [];
this.number = 0;
}
Test.prototype.push = function() {
this.array.push('hello');
this.number = 10...
It's obvious that a parent class's object can hold a reference to a child, but does this not hold true in case of parameterised collection ??
eg:
Car class is parent of Sedan
So
public void doSomething(Car c){
...
}
public void caller(){
Sedan s = new Sedan();
doSomething(s);
}
is obviously valid
But
public void do...
Is it possible to use JAXB to unmarshall xml to a specific Java class based on an attribute of the xml?
<shapes>
<shape type="square" points="4" square-specific-attribute="foo" />
<shape type="triangle" points="3" triangle-specific-attribute="bar" />
</shapes>
I would like to have a List of Shape objects containing a triangle and ...
I have a couple classes that have nearly identical code. Only a string or two is different between them. What I would like to do is to make them "x" from another class that defines those functions and then uses constants or something else to define those strings that are different. I'm not sure if "x" is inheritance or extending or wh...
I have a small program to demonstrate simple inheritance. I am defining a Dog class which is derived from Mammal. Both classes share a simple member function called ToString(). How is Dog overriding the implementation in the Mammal class, when i'm not using the virtual keyword? (Do i even need to use the virtual keyword to override membe...