Ok - this may be a very stupid question, but it's been bothering me.
Is there a language where
class Animal;
class Ape : public Animal
{...}
void doStuff(Animal* animalPtr)
{
cout << "doing animal stuff" << endl;
}
void doStuff(Ape* apePtr)
{
cout << "doing ape stuff" << endl;
}
Animal *ape = new Ape();
doStuff(ape);
would...
I understand the motivation for making individual methods of a class sealed/final, but what purpose does completely prohibiting inheritance from the class serve? While allowing overriding of certain methods can cause bad things to happen, I can't see how allowing inheritance from your class purely to add behavior to it without overridin...
Hi,
I'm trying to dispatch objects to separate method according to their subclass.
For instance, consider those 2 objects
class A extends I {}
class B extends I {}
and the method
void dispatch(I i) {}
in dispatch(), I'd like to invoke a method according to the type of i. Hence if i is actually of type A, the handlerA(A a) method ...
I have a pseudo-class in javascript that has a method to add and remove listeners to two buttons.
This is the code:
function FirstObj(secondObj){
this.loginButton = document.getElementById("login");
this.logoutButton = document.getElementById("logout");
this.secondObj = secondObj
}
FirstObj.prototype = {
manageListeners : funct...
Hi All,
I have worked as RPG400 programmer for 8 years. Since last 2-3 years not doing much programming as I am working as project Manager for non-AS400 projects.
Now I am planning to pickup OOP programming skills and continue fun with programming.
Looking for your help to decide which language should I learn Java or .Net?
What sh...
Respected Sir!
i should tell you that what i know and what i don't know about the asked question so that you can address the weak area of my understanding.
i know that c++ implements the polymorphism by using the Vtable which is array of pointers
each pointer points to the virtual function of the class, each class in the hierarchy has...
Respected Sir!
please explain how c++ implements this dynamic binding a pictorial representation would be more useful in understanding perspective.
or suggest a websigt which contains pictorial representations and full detail about this topic.
...
I have a question which is sonewhat more of a design question. I have a class which defines a bunch of functions. However, I want that the behaviour of some functions are changeable during runtime - or at least working like a plugin interface during design time. eg:
class MyClass {
public function doSomething();
}
$obj = new MyClas...
Ok my problem is as follows;
I have a class that describes a pet with this constructor;
public function __construct($name, $type, $age)
So what I want to do is make a number of pet objects, then I want to print all the attributes of all the objects of this class so that it looks something like this
What is the best way of going abou...
I'm creating a control for Google maps v2. While creating my control I've found a design challenge and want to find an appropriate solution. Here's the goods.
A custom Google control inherits from GControl;
myControl.prototype = new GControl();
Next I need to overload the initializer so here it is.
myControl.prototype.initilize = f...
I have wonder that many big applications (e.g. social websites such as facebook) are build with many languages into its platform.
They usually start with AJAX browser support, then scale down to PHP scripting, then move towards a powrful OOP technologie such as Java or .NET, and finally a primitive language to increase performance in cr...
Having a rectangle (A) and intersecting it with another rectangle (B), how could I extract the other rectangles created through that intersection (C,D,E & F)?
AAAAAAAAAAAAAA CCCFFFFDDDDDDD
AAABBBBAAAAAAA CCCBBBBDDDDDDD
AAABBBBAAAAAAA -> CCCBBBBDDDDDDD
AAAAAAAAAAAAAA CCCEEEEDDDDDDD
AAAAAAAAAAAAAA CCCEEEEDDDDDDD
And could th...
Hi,
I use zend framework and I would like to have your advice to modelize my classes.
I have 3 classes Patrimony.php Project.php and Version.php.
Version extends Project extends Patrmimony.
In other hand I have a folder structure like this /data/patrimonies/projects/versions/
I don't know if I have to use a Design Pattern or something ...
I have seen this question, but it's not what I'm looking for.
There used to be a plugin for JBuilder or Together that analyzed your code to find when one class depended too much on another class and things like that. It suggested refactoring based on GoF design patterns.
I have checked out PMD but it's not what I need, exactly. I'm lo...
Hello all.
Given class A, which contains sets of raw data, and class B, which contains a re-organized version (GUI ready) of that data I would like to make the raw data in A visible in B.
Clearly the raw data in class A is contained in private members. I would like to make that data visible in B though the use of something akin to the ...
Hi, I have some code where the model contains some classes like (vb.net pseudocode, but could be any OO language):
Enum AttributeType
Boolean
Date
String
End Enum
MustInherit Class Attibute
Must Override Function Type As AttributeType
End Class
Class BooleanAttribute: Attribute
Function Type As AttributeType
...
I am trying to figure out the best way to design something. I am writing an iPhone App and for the most part I am using async calls to a web service. This means that I cam setting up a URLConnection, calling start and letting it call me back when the data is available or an exception occurs. This works well and I think is the correct way...
hey there
Maybe this isn't the right place to ask, but I was wondering if there is any advice on how to start fixing an old-fashioned-style php script.
A few days ago I received an offer for developing an old PHP project, and by old-fashioned I mean the structure did not use OOP coding method and it doesn't have a definite framework...
What is the benefit of a static factory class as opposed to using an instance of the same object to return that object?
For example, from the N2 CMS, take a look at this code:
Newspage news = Factory.Persister.Get(itemID);
// Variable for news can set news related properties.
Factory.Persister.Save(news);
Factory is static and I am ...
Possible Duplicates:
Can you write object oriented code in C?
Object Oriented pattern in C ?
I remember reading a while ago about someone (I think it was Linus Torvalds) talking about how C++ is a horrible language and how you can write object-oriented programs with C. On having had time to reflect, I don't really see how al...