I'm trying to create a type that has multiple type parameters. I know how to make a type with one parameter:
type 'a foo = 'a * int
But I need to have two parameters, so that I can parameterize the 'int' part. How can I do this?
...
Hi, I'm working on a project and it's in a stage that I don't know what's wrong. Here's the simplified version:
The code:
class Base { // This base class is pure abstract
public:
virtual ~Base(); // Necessary to trigger destructors in inherited classes
virtual baseFunc() = 0;
};
...
I just realized how useful the little on-function can be.
Ex:
orderByLength = sortBy (compare `on` length)
But unfortunately, the inferred types can be somewhat counter-intuitive.
According to the very definition
f `on` g = \x y -> f (g x) (g y)
one could e.g. replace
(==) `on` length
with
\x y -> (length x) == (length y)
B...
hey,
there is something i still don't get.
for every class i declare there is a hidden vptr member pointing to the class virtual table.
let's say i have this declaration :
class BASE
{
virtual_table* vptr; //that's hidden of course , just stating the obvious
virtual void foo();
}
class DERIVED : public BASE
{
virtual_tabl...
In the following code:
public abstract class MyClass
{
public abstract bool MyMethod(
Database database,
AssetDetails asset,
ref string errorMessage);
}
public sealed class MySubClass : MyClass
{
public override bool MyMethod(
Database database,
AssetDetails asset,
ref string errorMe...
I'm trying to create my first hierarchy with the following classes (Account, CheckingAccount, and SavingsAccount) and can't figure out how to link the classes together.
Also, should the balance value be public in the header?
Currently it is not, and it shows "error in this context" every time it's mentioned in this main code.
[stackover...
We have a parent model Vehicle that is inherited to make classes Car, Truck, SUV. In our form, we allow the user to edit the data for a bunch of Vehicles, and one of the attributes for each vehicle is a select menu for "type". The HTML attribute is named vehicle_type and updates the actual Polymorphic type attribute in the Vehicle Model:...
I have been working with C++ for a few years now and have got good theoretical knowledge on the matter (I think).
However I've been missing involvement in good projects, sort of projects that really gets one going on the technologies.
So I intend to work on my own to get some good grip on C++ and related technologies.
'Have started with ...
The question is pretty much fully embedded in the title.
...
Hello, I have tried to use this code in VS2008 (and may have included too much context in the sample...):
class Base
{
public:
void Prepare() {
Init();
CreateSelectStatement();
// then open a recordset
}
void GetNext() { /* retrieve next record */ }
private:
virtual void Init() = 0;
virtu...
Perhaps my knowledge of inheritance and polymorphism isn't what I thought it was. Can anyone shed some light?
Setup (trivialization of problem):
class X {
};
class Y {
};
class Base {
public:
void f( X* ) {}
};
class Child: public Base {
public:
void f( Y* ) {}
};
Question: This should work, right?
int main( void ) {...
I'm running into an issue with an existing ActiveRecord::Observer model that records various Activities of a User the site. Everything was working really well, until I tried to observe the User class with the same Activity model that it uses to observe other models. Consider that:
class Activity < ActiveRecord::Base
belongs_to :user
b...
i'm just reading meyers "More Effective C++ 35 New Ways" - item 33, and he suggest there
always to inherit from an abstract base class, and not a concrete.
one of the reason he claims, which i can't quite get , is that with inheriting from an abstract class, treating array polymorphically (item 3 in the book) is not a problem.
can some...
Im trying to make something like an Rpg game atm but im really stuck on something i really dont know what to do anymore i really need help it might look like a noob question but please try to answer me >.< this is the parent class
namespace ConsoleApplication1
{
class Personaje
{
public Rango Damage;
public int D...
im trying to use this method to make my characters but i get the error:
inconsistent accessibility:return type'consoleapplication1.Enemigo' is less accesible than
method 'consoleapplication1.poringbuilder.makeporing()'
its the first time i get this error and i really dont know what to do,i have tried alot of different ways but i get the ...
Hi,
I have a Windows WCF serivce and Web client. My service has one method
[OperationContract]
SubmitOrder(OrderInfo info)....
// class used to pass all relevant data
[DataContract]
class OrderInfo
{
[DataMember]
OrderType Type;
// general order data
}
It was great until I have introduced new order types (controlled by OrderInfo....
I'm writing a plug-in for a 3D modeling program. I have a custom class that wraps instances of elements in the 3D model, and in turn derives it's properties from the element it wraps. When the element in the model changes I want my class(es) to update their properties based on the new geometry.
In the simplified example below. I have c...
can i overload or override methods just by using different return value ? is virtual matter in thie case ?
for example :
class A{
virtual int Foo(); // is this scenario possible with/without the keyword virtual
}
class B : public A {
virtual double Foo();
}
A* Base = new B();
int i = Base->Foo(); // will this just convert doubl...
In the ocaml language specification, there's a short section:
poly-typexpr ::= typexpr
| { ' ident }+ . typexpr
There's no explanation in the text, and the only instance of poly-typexpr is in defining a method type:
method-type ::= method-name : poly-typexpr
What does this allow me to do?
...
I am working on an interpreter for a toy language, just to learn about building an interpreter. I have already implemented a simple parser for the grammar that generates a parse tree. Now, the usual way of evaluating the parse tree would be to use polymorphism on the nodes of the parse tree, with code that looks something like below (in ...