inheritance

[C++] Why shall I use "using" keyword to access my base class method?

I wrote the code below in order to explain my issue. If I comment the line 11 (with the keyword "using"), the compiler does not compile the file and display this error: invalid conversion from 'char' to 'const char*'. It seems to do not see the method void action(char) of Parent class in Son class. Why the compiler behaves this way? Or h...

PHP [OOP] : Memory allocation for Inheritance

Please see the code bellow: class A { public x = 5; public y = 6; public z = 7; } class B extends A { public m = 1; public n = 2; } $a = new A(); $b = new B() From the above code let $a is allocating x amount of memory and $b is allocating y amount of memory; Now my question is which one is correct from bellow? ...

Fluent nHibernate Abstract class (non) Mapping problem

I have a base class, which has 2 derived class. Each derived class has a mapping file (they base class has non and it's abstract) Each derived class has an object that points to itself (which is defined in the base class); class Base { Base myManager; } class Derived1 : Base { } Class Derived2 : Base { } for each derived class ...

Is it possible to hide or lower access to Inherited Methods in Java?

I have a class structure where I would like some methods in a base class to be accessible from classes derived directly from the base class, but not classes derived from derived classes. According to the Java Language specification it is possible to override access specifications on inherited methods to make them more public, but not mo...

Inheriting from a virtual template class in C++

How do I inherit from a virtual template class, in this code: // test.h class Base { public: virtual std::string Foo() = 0; virtual std::string Bar() = 0; }; template <typename T> class Derived : public Base { public: Derived(const T& data) : data_(data) { } virtual std::string Foo(); virtual std::string Bar(); T data()...

Cancel global css inheritance

So I have a global reset rule: * { margin:0px; padding:0px; } I also have a LOT of tables with pre-defined cellpadding values. However, the global reset rule is killing all the cellpadding values. What would be the best way to get the cellpadding back without having to create a specific css rule for each table? (There are a lot of tab...

Passing a pointer to a base class to derived class's member functions in C++

How to access the derived class's data from one of its instances' member function that receives a pointer to the base class? I have: class Base{ public: virtual void compare(Base*)=0; }; class A: public Base{ int x; public: A(); void compare(Base*); }; cla...

C++ RTTI and Derived Classes

My C++ is a bit rusty. Here's what I'm attempting to do: class Cmd { }; class CmdA : public Cmd { }; class CmdB : public Cmd { }; ... Cmd *a = new CmdA (); Cmd *b = new CmdB (); First problem: cout << typeid (a).name () cout << typeid (b).name () both return Cmd * types. My desired result is CmdA* and CmdB*. Any way of accomplis...

Explicitly inherit from a class in the base module.

I have a class that inherits from class User. eg class MyClass < User end In my code base I have a class user class User end However I also have a plugin that provides a User class in a module TheirModule::User. This is a plugin that my application is tied to and I cannot remove it at the moment, however that is wh...

Why does PHP not automatically call parent constructors?

Fairly straightforward question. In C++ the parent constructor will be implicitly called before the child constructor, so what logic is there for PHP not to do things this way? EDIT: I've got a good answer from Lukman, but I was hoping for more of a reason why there is a difference. Maybe the question should be why does C++ not allow cu...

Service - client interface, architecture advice

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....

Java inherited method question

While studying for the SCJP 6 exam, I ran into this question in a test exam: class A{ private static String staticProperty = " a "; String getStaticProperty() { return staticProperty; } } class B extends A { private static String staticProperty = " b "; public static void main(String[] args){ new ...

Force derived class to call base function

If I derive a class from another one and overwrite a function, I can call the base function by calling Base::myFunction() inside the implementation of myFunc in the derived class. However- is there a way to define in my Base class that the base function is called in any case, also without having it called explicitly in the overwritten f...

Is there a way to automaticly call all versions of an inherited method?

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...

Determine what interfaces a type implements

Hey guys Just a quick one... How do I determine what interfaces a type implements? Cheers Anthony ...

Why there are no friend classes in C#?

Possible Duplicate: Why does C# not provide the C++ style friend keyword? A typical example where it might be needed I have a class with private Init() function and class factory which I would like to grant access to Init(); ...

.Net Binary Serialization inheritance

In a C# Context, I have a Class B which is marked as Serializable and who's inheriting form a Class A who's not marked as this. Can i find a way to serialize instance of B without marking A as serializable? ...

Objective-C inheritance method matching

I've come across a strange scenario related to class inheritance in Objective-C. Let's say i have three classes A, B and C that inherit from a base class X. Classes A, B and X have the constructor: - (id)InitWithString:(NSString*)someString andDelegate:(id<SomeProtocol>)aDelegate the only difference being that every class uses a diff...

Java abstract static Workaround

I understand that neither a abstract class nor an interface can contain a method that is both abstract and static because of ambiguity problems, but is there a workaround? I want to have either an abstract class or an interface that mandates the inclusion of a static method in all of the classes that extend/implement this class/interfac...

Can a Grails Domain Class inherit from a class that is not a domain class?

I tried to do this, but it insists on their being a table of the base class. I tried using tablePerHierarchy false as well and that didn't make any difference. I have a few domain classes that share a bunch of methods that operate on an inherited transient field. I had hoped that just having the class over in the non-domain secti...