Hey,
I have a few classes set up for a game, with XMapObject as the base, and XEntity, XEnviron, and XItem inheriting it.
MapObjects have a number of flags, one of them being MAPOBJECT_SOLID. My problem is that XEntity is the only class that correctly detects MAPOBJECT_SOLID. Both Items are Environs are always considered solid by the...
This is probably a silly question, but here it goes.Imagine you have the following classes:
public class C
{
}
public class D : C
{
//A subclass of C
}
public class A
{
C argument;
}
Now, I want to have a class B, that inherits from A.This class would obviously inherit the "argument" field, but I wish to force the "arg...
I've got a class that inherits from an interface. That interface defines an event that I'd like to subscribe to in the calling code. I've tried a couple of things, but they all resolve to false (where I know it's true). How can I check to see if a class implements a specific interface.
Here's what I've tried (note, the object in questio...
I have a "MustInherit" .NET class which declares a constructor with an integer parameter. However, Visual Studio gives me an error when I create any derived class stating that there is no constructor that can be called without any arguments. Is it possible to inherit the constructor with arguments?
Right now, I have to use
Public Sub N...
I'm having some problems with inheritance and the @PrePersist annotation.
My source code looks like the following:
_the 'base' class with the annotated updateDates() method:
@javax.persistence.Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Base implements Serializable{
...
@Id
@GeneratedValue...
I have the following classes:
Project
Person
Person > Developer
Person > Manager
In the Project model I have added the following statements:
has_and_belongs_to_many :people
accepts_nested_attributes_for :people
And of course the appropriate statements in the class Person. How can I add an Developer to a Project through the nested_a...
Hello, I have a class structure like
abstract class Animal {
public Animal(){
//init stuff..
}
}
class Cat : Animal {
public Cat(bool is_keyboard) : base() //NOTE here
{
//other init stuff
}
}
Now then, look at the noted line. If you remove : base() then it will compile without an error.
Why is this? Is there a wa...
I have an array of custom class Student objects. CourseStudent and ResearchStudent both inherit from Student, and all the instances of Student are one or the other of these.
I have a function to go through the array, determine the subtype of each Student, then call subtype-specific member functions on them.
The problem is, because thes...
I'm writing a class to represent a Pivot Collection, the root object recognized by Pivot. A Collection has several attributes, a list of facet categories (each represented by a FacetCategory object) and a list of items (each represented by a PivotItem object). Therefore, an extremely simplified Collection reads:
public class PivotCollec...
I have defined an Event class:
Event
and all the following classes inherit from Event:
AEvent BEvent CEvent DEvent
Now, with the info I gather from all these Event classes, I will make a chart. With AEvent and BEvent, I will generate points for that chart, while with CEvent and DEvent I will paint certain regions of the chart.
No...
I have two unit tests that should share a lot of common tests with slightly different setup methods. If I write something like
class Abstract < Test::Unit::TestCase
def setup
@field = create
end
def test_1
...
end
end
class Concrete1 < Abstract
def create
SomeClass1.new
end
end
class Concrete2 < Abstract
de...
Is it possible to override an internal method's behavior?
using System;
class TestClass
{
public string Name { get { return this.ProtectedMethod(); } }
protected string ProtectedMethod()
{
return InternalMethod();
}
string InternalMethod()
{
return "TestClass::InternalMethod()";
}
}
class ...
Given this sample code:
#include <iostream>
#include <stdexcept>
class my_exception_t : std::exception
{
public:
explicit my_exception_t()
{ }
virtual const char* what() const throw()
{ return "Hello, world!"; }
};
int main()
{
try
{ throw my_exception_t(); }
catch (const std::exception& error)
...
I would like to set up a foundation of classes for an application, two of which are person and student. A person may or may not be a student and a student is always a person. The fact that a student “is a” person led me to try inheritance, but I can't see how to make it work in the case where I have a DAO that returns an instance of pers...
Hi I am a C++ beginner just encountered a problem I don't know how to fix
I have two class, this is the header file:
class A
{
public:
int i;
A(int a);
};
class B: public A
{
public:
string str;
B(int a, string b);
};
then I want to create a vector in main which store either class A or class B
vect...
Should a Singleton class be allowed to have children? Should we seal it? What are the pro's and con's?
For being able to inherit from a Singleton class, we would have to make the constructor protected instead of private. Now, that will be fine in c#, but the protected word in java gives both child-classes and package-classes access to t...
I am trying to add a few extra methods to a matrix type from the pysparse library. Apart from that I want the new class to behave exactly like the original, so I chose to implement the changes using inheritance. However, when I try
from pysparse import spmatrix
class ll_mat(spmatrix.ll_mat):
pass
this results in the following err...
I have template that displays object elements with hyperlinks to other parts of my site. I have another function that displays past versions of the same object. In this display, I don't want the hyperlinks.
I'm under the assumption that I can't dynamically switch off the hyperlinks, so I've included both versions in the same template....
I am not clear with above statement. It would be great if anybody can explain how we can use inheritance to create a custom, type safe and null safe collection ?
Thanks
...
take this simple code:
class A{
public:
virtual void foo() = 0;
void x(){ foo(); }
};
class B: public A{ foo(){ ... } };
main(){
B b;
b.x();
}
What I want is to build an abstract class that will have a function that will call a function expecting it to be implemented in the derived class
The question is that I can't see...