My problem is like this. I have a XMLUtility class
public class XmlUtility
{
protected string FilePath;
protected string XMLFileName;
protected XmlDocument SettingsFile;
public XmlUtility(string inFilePath, string inXMLFileName)
{
FilePath = inFilePath;
XMLFil...
I frequently link objects to their parents using:
Video parent;
Sometimes I have objects that can be children of different object types, so do I:
int parentType;
Video parentVideo; // if parent == VIDEO then this will be used
Audio parentAudio; // if parent == AUDIO then this will be used
Is there a better way?
How do I work wi...
Which are the guidelines for choosing between template duck-typing and pure virtual base class inheritance? Examples:
// templates
class duck {
void sing() { std::cout << "quack\n"; }
};
template<typename bird>
void somefunc(const bird& b) {
b.sing();
}
// pure virtual base class
class bird {
virtual void sing() = 0;
};
c...
I need to extend the Networkx python package and add a few methods to the Graph class for my particular need
The way I thought about doing this is simplying deriving a new class say NewGraph, and adding the required methods.
However there are several other functions in networkx which create and return Graph objects (e.g. generate a ran...
$4.11/2 states -
An rvalue of type “pointer to member
of B of type cv T,” where B is a class
type, can be converted to an rvalue of
type “pointer to member of D of type
cv T,” where D is a derived class
(clause 10) of B. If B is an
inaccessible (clause 11), ambiguous
(10.2) or virtual (10.1) base class of
D, a progra...
I'm trying to do a simple implementation of the Specification pattern in my domain layer.
If I have a static class full of specifications like this:
public static class FooSpecifications
{
public static Func<Foo, bool> IsSuperhuman
{
get
{
return foo => foo.CanShootLasersOutOfItsEyes && foo.CanFly;
}
}
}
Then ...
Ok... in C++ you can new up a subclass from a static method in the base class with 'new this()' because in a static method, 'this' refers to the class, not the instance. That was a pretty damn cool find when I first found it and I've used it often.
However, in C# that doesn't work. Damn!
So... anyone know how I can 'new' up a subclass...
How to implement casting to a private base class in C++? I don't want to use hacks such as adding a friend etc. Defining public casting operator does not work.
EDIT :
For example I have:
class A {
//base class
}
class AX : private A {
//a child
}
class AY : private A {
//another specialized child
}
class B {
//base class
void do (A...
Hello,
Suppose I have the following model (generic example):
Person (base class)
Student (derived)
Teacher (derived)
Secretary (derived)
There are some common fields, such as first name, last name, phone nr., but several fields unique to each derived type (Student, Teacher, Secretary).
I would like to be able to display each type o...