derived

Method resolution in Comparer

Hi all, consider the following basic class layout: public class Base : IComparable<Base> { public int CompareTo(Base other) { //Do comparison } } public class Derived : Base, IComparable<Derived> { public int CompareTo(Derived other) { //Do comparison } } public class BaseComparer : IComparer<Base> { public in...

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

[c++] Type erasure and accessors

Hi, I used type erasure pattern in C++, i.e I hide a template class with an abstract class class Base{ virtual ~Base(){} //pure virtual methods... }; template<typename T> class Derived : Base{ Derived<T>(){} ~Derived(){} //public methods... private : vector<T> datas; }; problem : if I want to retrieve or modify datas, I have...

Weird compiler error and template inheritance

Could someone explain me why this code: class safe_bool_base { //13 protected: typedef void (safe_bool_base::*bool_type)() const; void this_type_does_not_support_comparisons() const {} //18 safe_bool_base() {} safe_bool_base(const safe_bool_base&) {} safe_bool_base& operator=(const safe_boo...

Why is this not allowed in C++?

Here is my code - #include<iostream> using namespace std; class base { private: public: void sid() { cout<<"base"; } }; class derived : private base { private: public: void sid() { cout<<"derived"; }...

Access 2K SQL OUTER JOIN using Derived Tables (i.e. subselect/subquery)

First, I am a noob, just trying to learn some Access/VBA/SQL, but I have been stumped by this issue. Shown below are the (9) tbl JOIN relations. This lists X records for each game_ID (X = number of players in game). I only want one record per game_ID where [game_players.player_ID] is a selected/special player (say, HERO ) [game_playe...

Derived classes

Hello, I have, for example, such class: class Base { public: void SomeFunc() { std::cout << "la-la-la\n"; } }; I derive new one from it: class Child : public Base { void SomeFunc() { // Call somehow code from base class std::cout << "Hello from child\n"; } }; And I want to see: la-la-la Hello from child C...

Derived class function

class Base { protected: int data; public: virtual int getData() { return data; } virtual void setData(int value) { data = value; } }; class Child : protected Base { public: void setData(int value) { Base::setData(value); cout << "Data is set.\n"; } }; class Worker { private: C...

ASP.NET model binding to base type

Hi, I have a BaseViewModel that my View Models all inherit from. public class MagazineViewModel : BaseOutputViewMode { public string TitleOfPublication { get; set; } } In my controller I use a factory method to give the corret View Model back based on an input: // e.g. viewModel contains an instance of MagazineViewModel BaseOu...