base class:
Class List(Of T)
Function Contains(ByVal value As T) As Boolean
derived class:
Class Bar : List(Of Exception) ' Exception type as example '
Function Contains(Of U)(ByVal value As U) As Boolean
compiler tells me that that two are the same, so I need to declare Overloads/new this second function.
But I want use U...
I'm learning C# and I encountered the following problem. I have two classes: base and derived:
class MyBase
{
public void MyMethod()
{
Console.WriteLine("MyBase::MyMethod()");
}
}
class MyDerived: MyBase
{
public void MyMethod()
{
Console.WriteLine("MyDerived::MyMethod()");
}
}
For now, withou...
I have an abstract class with a pure virtual function f() and i want to create a class inherited from that class, and also override function f(). I seperated the header file and the cpp file.
I declared the function f(int) in the header file and the definition is in the cpp file. However, the compiler says the derived class is still abst...
I'm not even sure what this principle is called or how to search for it, so I sincerely apologize if it has been brought up before, but the best way to do it is with an example.
class Properties
{
public string Name { get; set; }
}
class MyClass
{
class SubProperties: Properties
{
public override Name
{
...
I've looked for overriding guidelines for structs, but all I can find is for classes.
At first I thought I wouldn't have to check to see if the passed object was null, as structs are value types and can't be null. But now that I come to think of it, as equals signature is
public bool Equals(object obj)
it seems there is nothing preve...
Hi all,
I didn't figure out a better title for the question. Let me explain it better now:
The project I am working on is going to connect to a remote server, encrypt the session and send/receive data packets.
I'd like to make it modular enough, so I thought it'd be nice to use 3 distinct classes. These would be:
1) A socket wrapper cl...
Hi there!
I have a GWT serializable class, lets call it Foo.
Foo implements IsSerializable, has primitive and serializable members as well as other transient members and a no-arg constructor.
class Foo implements IsSerializable {
// transient members
// primitive members
public Foo() {}
public void bar() {}
}
Also a Service whi...
Assume you have a class that defines virtual methods with the access specifier public.
Can you change the access specifier on your overriden methods?
I am assuming no.
Looking for an explanation.
...
If I have a parent-child that defines some method .foo() like this:
class Parent {
public void foo(Parent arg) {
System.out.println("foo in Function");
}
}
class Child extends Parent {
public void foo(Child arg) {
System.out.println("foo in ChildFunction");
}
}
When I called them like this:
Child f = new Child();...
Hi there,
I'm trying for half an eternity now overriding QWidgets keyPressEvent function in QT but it just won't work. I've to say i am new to CPP, but I know ObjC and standard C.
My problem looks like this:
class QSGameBoard : public QWidget {
Q_OBJECT
public:
QSGameBoard(QWidget *p, int w, int h, QGraphicsScene *s);
signals:
v...
How can I view and override the full definition for built in classes? I have seen the library docs but am looking for something more.
For e.g. is it possible to override the Array Class such that the base index starts from 1 instead of 0, or to override .sort() of list to a sorting algorithm of my own liking?
...
I apologize if that title is confusing. This question may be a result of lack of coffee and/or sleep, but my mind is not working correctly right now.
Anyways, I have an inheritance tree like so (I know the architecture isn't ideal):
BaseClass
GeneralForm : Inherits BaseClass
SpecificForm : Inherits GeneralForm
And an object like so...
Hi folks,
I'm trying to add features to Django 1.2 admin's main page.
I've been playing with index.html, but features added to this page affect all app pages.
Any ideas on what template I'm supposed to use?
Thanks loads!!
...
I have few problems with my basic and would be thankful if someone can clear this.
1: What does it mean when I say base *b
= new derived; Why would one go for this? We very well separately can
create objects for class base and
class derived and then call the
functions accordingly. I know that
this base *b = new deriv...
Consider the following snippet:
import java.util.*;
public class EqualsOverload {
public static void main(String[] args) {
class Thing {
final int x;
Thing(int x) { this.x = x; }
public int hashCode() { return x; }
public boolean equals(Thing other) { return this.x ==...
Why C++ compiler gives this error? Why i can access lol() from B, but can not access rofl() [without parameters]. Where is the catch?
class A
{
public:
void lol(void) {}
void rofl(void) { return rofl(0);}
virtual void rofl(int x) {}
};
class B : public A
{
public:
virtual void rofl(int x) {}
};
int _tmain(int argc, _TCHAR*...
Ok, so I'm using Objective-C. Now, say I have:
TopClass : NSObject
- (int) getVal {return 1;}
MidClass : TopClass
- (int) getVal {return 2;}
BotClass : MidClass
- (int) getVal {return 3;}
I then put objects of each type into an NSMutableArray and take one out. What I want to do is run the getVal func on the appropriate object type, ...
public class B {
static int i =1;
public static int multiply(int a,int b)
{
return i;
}
public int multiply1(int a,int b)
{
return i;
}
public static void main(String args[])
{
B b = new A();
System.out.println(b.multiply(5,2));
System.out.println(b.multipl...
I'm debugging a sample tutorial snippet and am confused about the overriding of setters.
I declare and override as shown here:
//
// PolygonShape.h
//
@interface PolygonShape : NSObject
{
int numberOfSides;
}
@property int numberOfSides;
//
// PolygonShape.m
//
@synthesize numberOfSides;
// custom setter.
- (void) setnumber...
I want to explicitly implement an interface method on a base class.
Beyond this, I wanted to make this method virtual so I could override it on a derived class, but explicitly implemented methods do not allow this.
I have tried making a protected virtual method in the base, calling this from the interface method, and then overriding th...