|
Hi
I have 2 base interfaces, IViewBase (which all views will implement) and IPresenterBase (which all presenters will implement):
public interface IViewBase { } public interface IPresenterBase { IViewBase View { get; set; } }
Then i've created a new interface...
Started by Sys on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You probably want to use generics here:
public interface IViewBase { } public interface IPresenterBase<T> where T : IViewBase { T View { get; set; } }
then:
public interface ILogPresenter : IPresenterBase<ILogView> { } public interface ILogView... .
|
|
Say I have something like -- this is just an example mind you.
class Car { void accelerate(); void stop(); } class Person { void drive(Car car); } class Toyota : public Car { void accelerateUncontrollably(); } class ToyotaDriver : public Person { void...
Started by DevDevDev on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Derived classes.
The implication is that it can be safely downcasted to the type that matches that tag .
|
|
#include <iostream> using namespace std; class Base { public: Base(){cout <<"Base"<<endl;} virtual ~Base(){cout<<"~Base"<<endl;} virtual void foo(){ cout<<"foo base"<<endl;} }; class Derived: private Base { public...
Started by Alien01 on
, 6 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The same counts to the own class any more....
Why its not possible to create Derived object with base pointer????
Because the base is private from the outside, your class Derived is not a subclass of Base , only from inside the class itself.
|
Ask your Facebook Friends
|
Can I force a parent class to call a derived class's version of a function?
class Base(object): attr1 = '' attr2 = '' def virtual(self): pass # doesn't do anything in the parent class def func(self): print "%s, %s" % (self.attr1, self.attr2) self.virtual...
Started by Paul on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If there is no instance of Derived involved, then there's no suitable self virtual(self): pass def func(self, cb): print....
If you instantiate a Derived (say d = Derived() ), the .virtual that's called by d.func() is Derived.virtual .
|
|
What's the difference between a derived object and a base object in c++,
especially, when there is a virtual function in the class.
Does the derived object maintain additional tables to hold the pointers
to functions?
Started by MainID on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
A derived object can override
a public colon.
derived - is the object the inherits his father's public (and protected) members.
Derived is Base, but Base is not a Derived
base- is the object you are deriving from.
|
|
I want to partially specialize an existing template that I cannot change ( std::tr1::hash ) for a base class and all derived classes. The reason is that I'm using the curiously-recurring template pattern for polymorphism, and the hash function is implemented...
Started by Doug on
, 3 posts
by 2 people.
Answer Snippets (Read the full thread at stackoverflow):
Derived, typename boost::enable_if< std::tr1::is_base_of<CRTPBase<Derived>, Derived>.
|
|
Why is an array called a derived data type?
Started by Subodh on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
So, due to this, array is called the derived data type also referred some times as derived....
(Actually, the version data type, holding N items of the base data type .
The reason is that they are derived from the fundamental data types.
|
|
( Objective C ) How would I call a base class function using a derived pointer where foo is overridden in the derived class. Essentially the equivalent of this C++ code
base* b_ptr = 0 ; derived* d_ptr = new derived() ; d->base::foo() ;
I would think...
Started by Steve on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Derived *d = [Derived new]; // call doSomething on derived class [d doSomething.
Runtime.h> ...
|
|
Hi,
Consider these classes,
class Base { ... }; class Derived : public Base { ... };
this function
void BaseFoo( std::vector<Base*>vec ) { ... }
And finally my vector
std::vector<Derived*>derived;
I want to pass derived to function BaseFoo...
Started by andreas buykx on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
You could change your variable from a vector<Derived*> to a vector<Base*> and insert Derived objects into ....
This is explained in the C++ FAQ here.
And vector<Derived*> are unrelated types, so you can't do this.
|
|
Is there any performance gain using a CTE over a derived table?
Started by D Scott on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The server was fairly well loaded, the variation in times on runs was pretty significant, and I can't believe the execution plan was that different, but it still seemed ... .
I've used CTEs a lot and it does actually appear to run faster in some scenarios .
|