derived-class

Using inheritance in constructor (publix X () : y)

Hi, I have just seen following code but I do not understand the derivation of base class right in the constructor declaration. What is this and is this possible with ordinal methods? public SplashAppContext(Form mainForm, Form splashForm) : base(splashForm) { this.mainForm = mainForm; splashTimer.Tick += new EventHandler(SplashTimeUp); ...

Calling a function from a derived template class

My base class: //Element.h class Element { public: Element(); virtual ~Element(){}; // not sure if I need this virtual Element& plus(const Element&); virtual Element& minus(const Element&); }; Derived template class: //Vector.h #include "Element.h" template <class T> class Vector: public Element { T x, y, z; public: //constructors...

C++: pointer-to-member-func, template & inheritance mixup

I am trying to create a generic "callback" object that will hold arbitrary data and invoke member functions of related classes. Due to internal policy, I cannot use Boost. The callback object looks like this: template<typename Object, typename Data> class Callback { public: typedef void (Object::*PHandler)(Callback*); Callback(Obj...

C++/CLI: finding base class of a class being defined

Hello, I'd like to find base class of a class being defined. I tried to use __super, but it seems it can be used only to call base class' methods. Some sample code: ref struct Team { ref struct ScoreDescription {}; ScoreDescription Score; }; ref struct FootballTeam : public Team { ref struct ScoreDescription : public __sup...

Where's the best place to store a custom "User" object for the duration of an ASP.NET session?

I have an ASP.NET application that needs to remember some info about a user (and what company they are from) across pages, within a session. I imagine this is a requirement of just about any ASP.NET application of a certain size. I've used a few different approaches over the years. In the past, I've passed around an id in querystring p...

Constructor of derived class with base instance as parameter

I have this code: #include <stdio.h> class A { public: A() { printf("A::A()\n"); } A(const A &a) { printf("A::A(A &a)\n"); } A &operator=(const A &a) { printf("A::operator=\n"); } }; class B : public A { public: B() { printf("B:B()\n"); } B(const A &a) : A(a) { printf("B::B(A &a)\n"); } B &operator=(const B &b)...

Why does my C++ subclass need an explicit constructor?

I have a base class that declares and defines a constructor, but for some reason my publicly derived class is not seeing that constructor, and I therefore have to explicitly declare a forwarding constructor in the derived class: class WireCount0 { protected: int m; public: WireCount0(const int& rhs) { m = rhs; } }; class WireCo...

Should i definitely have a constructor in a derived class?

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...

iphone best way derive UITableViewController

Hi all! I wish create my personal UITableViewController and use it into my UIViewController using interface builder... what's the best and fast way to do this? thanks in advance ...

C++ Boost serialization Serializing templated derived classes

Hi, i would like to serialize a class with an attribute as a list of pointers on a generic class This is the parent class from which the generic class derives : class Base{ public : friend class boost::serialization::access; virtual ~Base(){} template<class Archive> void serialize(Archive & ar, ...

accessing derived class from base class object problem

I have a kind of weird situation ... I have a User Control in WPF witch in turn has some other User Controls attached to it, then I have a huge C# code file with a big algorithm which needs access to the User Control UI Elements and methods, this hole process works with a Timer which sends data to the C# code file algorithm from the Use...

C# derived classes, overload resolution

Ok, I have an some different objects that are derived from a base class and I've put a bunch of them in a list. I want to loop through the list and push each to a method. I have separate methods with each one's type signature, but the compiler is complaining. Can someone explain why? Is this an opportunity to use Generics, and if so,...

Derived classes as return value

Given these C# classes (generated by WCF, I can't change these): public SysState GetSysState(); public class SysState { /* nothing much here */} public class Normal : SysState { /* properties & methods */ } public class Foobar : SysState { /* different properties & methods */ } My code (currently): SysState result = GetSysState();...

Cast base class to derived class python (or more pythonic way of extending classes)

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...

c++ handling derived class that's self referencing

So suppose I have a tree class like this in c++ class Node{ void addChild(Node*); /*obvious stuff*/ protected: Node* parent; vector<Node*> children } class specialNode : public Node{ void addChild(specialNode*); /*obvious stuff*/ /*special stuff*/ } Now whenever I access the children in special...

Using declaration (Derived class)

struct B1{ int d; void fb(){}; }; struct B2 : B1{ using B1::d; using B1::fb; int d; // why this gives error? void fb(){} // and this does not? }; int main(){} Is it because, B1::fb() is treated as B1::fb(B1*) and B2::fb() treated as B2::fb(B2*)? That is, does the implicit parameter, help in disting...

Typical problem on Inheritance

Possible Duplicate: Why is this not allowed in C++? Why is this not allowed in C++...?? class base { private: public: void func() { cout<<"base"; } }; class derived : private base { private: public: void func() { cout<<"derived"; ...

Deep copy of a derived python object

I have an object in python that is derived from QtGui.QGraphicsPixmapItem with a few basic attributes and methods. After calling deepcopy on a reference to this object, I get an error saying that underlying C/C++ object has been deleted when I try to use the copy. I had received this error before, and it occured when I didn't call the ba...

How to create smart controls for a variety of related objects

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...

Non-virtual derivation: what do I really get from the compiler?

Hi, I am wondering what is produced by the compiler when using non-virtual derivation: template< unsigned int D > class Point { int[D]; // No virtual function // ... }; class Point2 : public Point<2> {}; class Point3 : public Point<3> {}; Does the derivation here only imply compile-time checks? Or is there some other ove...