base-class

Erroneous private base class inaccessible?

无人久伴 提交于 2019-12-03 13:18:05
Compiling this code using g++ 4.2.1: struct S { }; template<typename T> struct ST { }; template<typename BaseType> class ref_count : private BaseType { }; template<typename RefCountType> class rep_base : public RefCountType { }; class wrap_rep : public rep_base<ref_count<S> > { typedef rep_base<ref_count<S> > base_type; // line 11 }; I get: bug.cpp:1: error: ‘struct S’ is inaccessible bug.cpp:11: error: within this context However, if I change the wrap_rep class to use ST : class wrap_rep : public rep_base<ref_count< ST<int> > > { typedef rep_base<ref_count< ST<int> > > base_type; }; it

Raise Base Class Events in Derived Classes C#

坚强是说给别人听的谎言 提交于 2019-12-03 12:43:38
I have a base class DockedToolWindow : Form, and many classes that derive from DockedToolWindow. I have a container class that holds and assigns events to DockedToolWindow objects, however I want to invoke the events from the child class. I actually have a question about how to implement what this MSDN site is telling me to do. This section below is giving me the problem: // The event. Note that by using the generic EventHandler<T> event type // we do not need to declare a separate delegate type. public event EventHandler<ShapeEventArgs> ShapeChanged; public abstract void Draw(); //The event

Scala: How can I make my immutable classes easier to subclass?

若如初见. 提交于 2019-12-03 11:40:32
问题 I've recently created an immutable class supporting operations like +, -, etc. that returns a new instance of that class when it is changed. I wanted to make a subclass of that class to add a bit of state and functionality but now I'm running into a problem in that all the original class's methods return instances of itself rather than the subclass. Based on my current limited knowledge of Scala I can come up with this: class Foo(val bar:Int) { def copy(newBar:Int) = new Foo(newBar) def +

Why is a base class in C# allowed to implement an interface contract without inheriting from it?

走远了吗. 提交于 2019-12-03 05:51:26
问题 I've stumbled upon this "feature" of C# - the base class that implements interface methods does not have to derive from it . Example: public interface IContract { void Func(); } // Note that Base does **not** derive from IContract public abstract class Base { public void Func() { Console.WriteLine("Base.Func"); } } // Note that Derived does *not* provide implementation for IContract public class Derived : Base, IContract { } What happens is that Derived magically picks-up a public method,

Do you have a common base class for Hibernate entities?

谁说胖子不能爱 提交于 2019-12-03 04:56:01
问题 Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks? Example: @MappedSuperclass() public class BaseEntity { private Long id; private Long version; ... @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() {return id;} public void setId(Long id) {this.id = id;} @Version public Long getVersion() {return version;} ... // Common properties @Temporal(TemporalType.TIMESTAMP) public

How do derived class constructors work in python?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 04:48:17
I have the following base class: class NeuralNetworkBase: def __init__(self, numberOfInputs, numberOfHiddenNeurons, numberOfOutputs): self.inputLayer = numpy.zeros(shape = (numberOfInputs)) self.hiddenLayer = numpy.zeros(shape = (numberOfHiddenNeurons)) self.outputLayer = numpy.zeros(shape = (numberOfOutputs)) self.hiddenLayerWeights = numpy.zeros(shape = (numberOfInputs, numberOfHiddenNeurons)) self.outputLayerWeights = numpy.zeros(shape = (numberOfHiddenNeurons, numberOfOutputs)) now, I have a derived class with the following code: class NeuralNetworkBackPropagation(NeuralNetworkBase): def _

ExecuteCore() in base class not fired in MVC 4 beta

核能气质少年 提交于 2019-12-03 04:40:58
问题 I have a base controller class: And all my other controller inherits this BaseClass like this All this works great in MVC3 (test again today, it really works) but it seems that the ExecuteCore in BaseController is not fired any more in MVC 4 beta. Any idea? Or Anything huge has changed under the hood? Thanks very much. public class BaseController : Controller { private string _myData; public string MyData { get { return _myData; } } protected override void ExecuteCore() { _myData = "I am

Scala: How can I make my immutable classes easier to subclass?

无人久伴 提交于 2019-12-03 02:09:58
I've recently created an immutable class supporting operations like +, -, etc. that returns a new instance of that class when it is changed. I wanted to make a subclass of that class to add a bit of state and functionality but now I'm running into a problem in that all the original class's methods return instances of itself rather than the subclass. Based on my current limited knowledge of Scala I can come up with this: class Foo(val bar:Int) { def copy(newBar:Int) = new Foo(newBar) def + (other:Foo):This = copy(this.bar + other.bar) } class Subclass(barbar:Int) extends Foo(barbar) { override

ExecuteCore() in base class not fired in MVC 4 beta

痴心易碎 提交于 2019-12-02 17:09:05
I have a base controller class: And all my other controller inherits this BaseClass like this All this works great in MVC3 (test again today, it really works) but it seems that the ExecuteCore in BaseController is not fired any more in MVC 4 beta. Any idea? Or Anything huge has changed under the hood? Thanks very much. public class BaseController : Controller { private string _myData; public string MyData { get { return _myData; } } protected override void ExecuteCore() { _myData = "I am doing something"; base.ExecuteCore(); } } public class HomeController : BaseController { public

Classes within python part 1 [closed]

走远了吗. 提交于 2019-12-02 13:24:06
I am trying to create a python class based on this class. I am trying to have it return the person’s wages for the week (including time and a half for any overtime. I need to place this method following the def getPhoneNo(self): method and before the def __str__(self): method because I am trying to use this method in another program. I f anyone can help out. class PersonWorker: def _init_(self, firstName, lastName, phoneNo): self.firstName= firstName self.lastName= lastName self.phoneNo= phoneNo def getFirstName(self): return self.firstName def getLastName(self): return self.lastName def