I want to use pimpl idiom with inheritance.
Here is the base public class and its implementation class:
class A
{
public:
A(){pAImpl = new AImpl;};
void foo(){pAImpl->foo();};
private:
AImpl* pAImpl;
};
class AImpl
{
public:
void foo(){/*do something*/};
};
And I want to be able to create the der...
I am writing an application where we will need to extend a basic entity into a number of different things (eg employee, vehicle etc). The design is as such that there is a Entity table and a second table with type specific values eg an employee will have an ID Number but a vehicle will have a registration number.
I have inherited from ...
Hello,
I have a question about inheritance and casting in Java. I have the following two example classes and a test class, and I state my question after the classes:
public class Automobile {
public int var;
public Automobile () {
var = 1;
}
public String toString () {
return "AUTOMOBILE: " + var;
}
}
...
Is it possible to have a plugin in the parent which is deactivated, and when the child inherits this plugin it gets automatically activated ?
Thanks in advance, kuku
...
Okay so I have a scenario similar to the below code, I have a parent class that implements IComparable and a child class.
class Parent : IComparable<Parent>
class Child : Parent
Child a = new Child();
Child b = new Child();
a.CompareTo(b);
Now the above works fine, i can compare two of the child objects to each other no problem
L...
I have a class (class A) that is designed to be inherited by other classes written by other people.
I also have another class (class B), that also inherits from A.
B has to access some A's member functions that shouldn't be accessed by other inheriting classes.
So, these A's member functions should be public for B, but private for othe...
I am creating an abstract class. I want each of my derived classes to be forced to implement a specific signature of constructor. As such, I did what I would have done has I wanted to force them to implement a method, I made an abstract one.
public abstract class A
{
abstract A(int a, int b);
}
However I get a message saying the a...
I'm trying to create a generic graphics export tool which works by implementing the Graphics interface and intercepts and interprets the calls to its various methods. However although I can do this successfully for a single component my Graphics class is being replaced when I use it on a component which contains other components. Stran...
Hello anyone. Here is the situation. I have two classes: Action, and MyAction, last one is declared as:
class MyAction extends Action {/* some methods here */}
All i need is method in Action class(only in it, cuz there will be a lot of inherited classes, and i don't want to implement that method in all of them), which will return clas...
Maybe Im to tired, but this seems to be a vary basic question. Suddenly my inheritance chain stopped working. Writing a small basic test application proved that it was me that was wrong (so I cant blame the compiler).
I have a base class, with the default behavior in a virtual function. A child class derives from that and changes the be...
I wish to declare a new dojo class inheriting from an existing dojo class, but with my own choice of default values for the class's properties. (The user can still override those values.)
I am declaring my own version of the dijit.form.FilteringSelect such that:
the hasDownArrow property defaults to false (rather than the standard tr...
Hi
I'm working on a class that inherits from another class, but I'm getting a compiler error saying "Cannot find symbol constructor Account()". Basically what I'm trying to do is make a class InvestmentAccount which extends from Account - Account is meant to hold a balance with methods for withdrawing/depositing money and InvestmentAcco...
Is it acceptable to use the word 'Base' in a class name which is a the bottom of the inheritance tree?
I have always found this a bit of a cop-out, just wondering if anyone agrees with me.
For example, if I am refactoring certain elements from MyClassA and MyClassB into a common base class, I'd be tempted to create a MyBaseClass from w...
Is there any way you can implement inheritance in Reporting Services? I would like to have a master report, that contains the standard header and footer + some info in the beginning of the report, as well as containing some report parameters. Then I would like to create a new report that inherits the master reports design and then I co...
class Super {
public void anotherMethod(String s) {
retValue(s)
}
public String retValue(String s) {
return "Super " + s;
}
}
class Sub extends Super {
public void anotherMethod(String s) {
retValue(s)
}
public String retValue(S...
struct TimerEvent
{
event Event;
timeval TimeOut;
static void HandleTimer(int Fd, short Event, void *Arg);
};
HandleTimer needs to be static since I'm passing it to C library (libevent).
I want to inherit from this class. How can this be done?
Thanks.
...
Here's a simplified version of my class:
public abstract class Task
{
private static object LockObject = new object();
protected virtual void UpdateSharedData() { }
protected virtual void UpdateNonSharedData() { }
public void Method()
{
lock(LockObject)
{
UpdateSharedData();
}
...
In java, is there ever a case for allowing a non-abstract class to be extended?
It always seems to indicate bad code when there are class hierarchies. Do you agree, and why/ why not?
...
Hello,
I have a question about default constructors and inheritance in Java.
Generally, if you write a class and do not include any constructor, Java provides automatically for you a default constructor (one without parameters), which initializes all instance variables of the class (if there are any) with some default values (0, null,...
I have 3 classes in different files:
X
|
-------
| |
Y Z
I will be creating several objects of inherited classes Y and Z.
A specific function in class Z should be executed only if some flag variable is set by class Y.
Where should I create this flag variable (which class) and what should be the declaration be like (sta...