A C++ programmer trying to learn Haskell here. Please excuse this probably easy question. I want to translate a program that represents 3D shapes. In C++ I have something like:
class Shape {
public:
std::string name;
Vector3d position;
};
class Sphere : public Shape {
public:
float radius;
};
class Prism : public Shape {
publ...
I've tried to understand some of the posts of similar, but don't quite understand their purposes and thought I'd explain my own...
I have a class -- fully defined with code with properties, and methods. Many methods are virtual to be overriden by further derived class. So, I have something like the following
Class_Main
-- Class_A ...
Hi
As per java, instance method resolution is based on runtime types of the arguments.
But while resolving instance variable it uses different approach as shown below.
Output of program is ..
Child
Parent
ParentNonStatic
Here First output is based on runtime types of the argument but third output is not.
can any on...
Hi guys,
I'm trying to make a Ruby class that is very flexible as to its type and hopefully can inherit properties from a number of other classes depending on the values its initialized with:
class Test
def initialize(type,etc)
case type
when "stringio"
inherit_from_stringio_with_data(etc)
when "list"
inherit_...
If I have in C++:
class A {
private: virtual int myfunction(void) {return 1;}
}
class B: public A {
private: virtual int myfunction(void) {return 2;}
}
Then if I remove virtual from the myfunction definition in class B, does that mean that if I had a class C based on class B, that I couldn't override the myfunction since it w...
Hi !
When I use a Theme like link text in my WPF App, I notice a difference between the Items of ListBoxes and ComboBoxes: When I add a an object of my own class to their Items Collection, the created item looks themed. If I make my own class inherit from ListBoxItem/ComboBoxItem, the resulting Visualization looks unthemed.
How can I d...
Since class friendship is not inherited in C++, what's the best way to "fake" it?
I was thinking about exposing the friend class's private interface through protected methods in the to-be-inherited base-class, but that results in having to write (and maintain) the same interface twice.
Are there any other ways?
...
I have two classes in C++, where one inherits from the other:
class A {
public:
virtual void Initialize(){
m_MyString = "Default value";
}
protected:
string m_MyString;
}
class B : public A {
public:
void Initialize(){
A::Initialize();
m_MyString = "New Value";
}
}
Is there a differenc...
I am working with MVP in ASP.NET and wanted see if there is an easier/cleaner way to do this.
I have a presenter with a view. It turns out I can reuse some of the view properties and presenter methods in other views/presenters in the same application area.
Lets say I have a Bar, which is logically a Foo. The base presenter, FooPresen...
Our software represents each device as a concrete class. So let's say I have a class named Cpu-Version-1, which is derived from a abstract baseclass called Device. Now, the CPU vendor wants to release the economic version of this CPU ( Cpu-Version-2 ), which is a feature reduced version of Cpu-Version-1 (obviously for a lower price ). 90...
Hi,
I'm reading through the Doctrine documentation but I can't find a way to implement the type of inheritance I want to use.
I would like to set up a hierarchy like so:
Node -> Something -> Something Else
With Node being the main parent.
I would like to store data common to everything in a node table, eg date of creation, update e...
Hey guys!
I have a class which has a function to retrieve children elements from a database. The following code will be rather pseudo cause I want to keep it as easy as possible.
abstract class SomeHostObject extends SomeObject {
function getChild($identifier) {
global $database;
$id = $database->select('Some MySQL Quer...
I can't seem to find an answer on this and just want to make sure it's an ok coding standard. I have Interface A that is used by many different classes and don't want interface A to change. I came across a new requirement that will require an enum to be needed by many of the classes that Implement Interface A, but not all the classes n...
Hi there,
can anyone help, i have a small issue, i have an interface and also a base interface, when i try to do
.Dispose()
It doesn't find the method as its implemented on my sub class NOT base.. and it always seems to want to call the base - even though i specifically put the namespace in front of the parameter on the constructor...
If my models look like this:
(app/models/letter.rb)
class Letter < ActiveRecord::Base
def cyrilic_equivilent
# return somethign similar
end
end
class A < Letter
end
class B < Letter
end
Can my migrations also follow this pattern:
class CreateLetter < ActiveRecord::Migration
def self.up
create_table :letters do |t|
...
This is a piece of my code, I have more class like MathStudent, ArtStudent, etc. which inherits Student class. When I tried to compile, it says "forbids declaration of `vector' with no type," what is the problem here?
thanks
class Student {
public:
typedef vector<Student> Friends; // something wrong here?
virtual unsigned int ...
I have a nice interface, and I want to implement one member of it in a base class so the clients can derive from the base class and have less boiler-plate to write. However, even though declared abstract, the compiler complains that the class does not implement the interface?!? How is this supposed to be done?
Code in question:
public ...
Consider the Java code below, what would happen if there were no paintComponent method in JPanel class?
...
import javax.swing.JPanel;
public class ShapesJPanel extends JPanel
{
public void paintComponent( Graphics g )
{
super.paintComponent( g );
//more codes here
}
}
...
Let's say I have an existing database with the following 3 tables:
Table1:
(PK)T1ID1
(PK)T1ID2
Table2:
(PK)T2ID1
Table3:
(FK)T1ID1
(FK)T1ID2
(FK)T2ID1
(Where the 3 keys come from the tables above)
My question is: How do I map Table3 with Fluent NHibernate?
What is confusing to me is what to do about the fact that its composite keys c...
Hi as far as I see in Python variables are untyped. So now I want to have a baseclass
class baseClass:
def x():
print "yay"
and two subClasses
class sub1(baseClass):
def x():
print "sub1"
class sub2(baseClass):
def x():
print "sub2"
in other programming languages I can develop against interfaces just like
baseClass c =...