Questions tagged [derived]

429 questions
6
votes
1 answer

ASP.NET MVC 3.0 Model binding with Base and Derived classes?

Hi all I have a base class called Vehicle and I have all the properties common to all vehicles in there and I have multiple derived classes called Car, Jeep which derive from Vehicle and add more properties Ex: public class Vehicle { public…
icoolguy
  • 75
  • 2
  • 5
5
votes
2 answers

Using typedef and typename inside a template

I want to define a type name in a templated class that I can use elsewhere to refer to the type of a member in the class. template class CA { public: //typedef typename T::iterator iterator_type; typedef typename T ElementType1; //…
Robotbugs
  • 4,307
  • 3
  • 22
  • 30
5
votes
7 answers

implementing abstract methods/classes in java

Can I implement abstract methods in an abstract base class A in java? If the answer is yes and there is an implemented abstract method in a base class A and there is a derived class B from A (B is not abstract). Does B still has to implement that…
Greg Oks
  • 2,700
  • 4
  • 35
  • 41
5
votes
3 answers

calling a template function of a derived class

I'm having a problem in C++ with calling a function of a derived class while having a pointer to the base class. EDIT: Some answers referred me to CRTP but my point is that I need to have a pointer to the "Base*" class not "Base*" because I'm…
koby meir
  • 437
  • 7
  • 16
5
votes
0 answers

JavaFX add opacity to derived color via CSS

So, I've got a derived color like this: derive(-fx-base, 70%) it has no opacity yet. Is there a way to add opacity to it?
xeruf
  • 2,602
  • 1
  • 25
  • 48
5
votes
3 answers

Weird compiler error and template inheritance

Could someone explain me why this code: class safe_bool_base { //13 protected: typedef void (safe_bool_base::*bool_type)() const; void this_type_does_not_support_comparisons() const {} //18 safe_bool_base() {} …
ereOn
  • 53,676
  • 39
  • 161
  • 238
5
votes
2 answers

Subquery using derived table in Hibernate HQL

I have a Hibernate HQL question. I'd like to write a subquery as a derived table (for performance reasons). Is it possible to do that in HQL? Example: FROM Customer WHERE country.id in (SELECT id FROM (SELECT id FROM Country where type='GREEN')…
Vladimir
  • 61
  • 1
  • 4
5
votes
5 answers

Identifying derived types from a list of base class objects

This may seem kind of "homework-ish" and/or trivial, but it is for a real business purpose; it's just the easiest way I could think of to explain what I'm conceptually trying to do. Suppose I have an Animal class, and some other classes (Bird, Cat,…
Ron Lhufasen
5
votes
5 answers

Avoid slicing of exception types (C++)

I am designing an exception hierarchy in C++ for my library. The "hierarchy" is 4 classes derived from std::runtime_error. I would like to avoid the slicing problem for the exception classes so made the copy constructors protected. But apparently…
shojtsy
  • 1,710
  • 3
  • 17
  • 24
5
votes
3 answers

C#: Inheriting separate static members for derived classes

My problem in brief: class A { /* Other stuff in my class*/ protected static staticMember; } class B : A { /* Other stuff in my class*/ // Will have A.staticMember but I want B.staticMember (same type) } class C : A { /* Other…
Calmarius
  • 18,570
  • 18
  • 110
  • 157
5
votes
2 answers

Generic function on a list of derived class

I feel my question is pretty dumb, or another way to put it is : I'm too lost in my code to see a workaround for now. Stay too long on a problem, and your vision becomes narrower and narrower ><. Plus I'm not good enough with inheritance,…
Chouppy
  • 75
  • 6
5
votes
3 answers

How to access template parameters from a derived class?

I have a template class Base and class Derived : public Base<1> ... is there a way to access the int N from inside the definition of a Derived::myMethod() (instead of getting the compiler error "use of undeclared identifier 'N'")? More…
PhilippJS
  • 51
  • 2
4
votes
1 answer

Converting a Derived Class to Base Class for WCF Serialisation

I have two classes... [Serializable] [DataContract] public class A { [DataMember] public string _a { get; set; } [DataMember] public bool _b { get; set;…
ornah
  • 41
  • 2
4
votes
2 answers

access base class variable in derived class

class Program { static void Main(string[] args) { baseClass obj = new baseClass(); obj.intF = 5; obj.intS = 4; child obj1 = new child(); Console.WriteLine(Convert.ToString(obj.addNo())); …
sam
  • 149
  • 4
  • 5
  • 10
4
votes
3 answers

Prevent calling base class implemented interface method in the derived class C#

Is it possible to implement an interface in a base class and allow calling/overriding the implemented method in the first derived class level but prevent calling it from any further derived classes? public interface IInterfaceSample { …
Anas
  • 61
  • 1
  • 4
1 2
3
28 29