Search Results

Search found 40393 results on 1616 pages for 'single table inheritance'.

Page 12/1616 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Trouble with inheritance

    - by Matt
    I'm relatively new to programming so excuse me if I get some terms wrong (I've learned the concepts, I just haven't actually used most of them). Trouble: I currently have a class I'll call Bob its parent class is Cody, Cody has method call Foo(). I want Bob to have the Foo() method as well, except with a few extra lines of code. I've attempted to do Foo() : base(), however that doesn't seem to work like. Is there some simple solution to this?

    Read the article

  • Compile error on inheritance of generic inner class extending with bounds

    - by Arne Burmeister
    I have a problem when compiling a generic class with an inner class. The class extends a generic class, the inner class also. Here the interface implemented: public interface IndexIterator<Element> extends Iterator<Element> { ... } The generic super class: public abstract class CompoundCollection<Element, Part extends Collection<Element>> implements Collection<Element> { ... protected class CompoundIterator<Iter extends Iterator<Element>> extends ImmutableIterator<Element> { ... } } The generic subclass with the compiler error: public class CompoundList<Element> extends CompoundCollection<Element, List<Element>> implements List<Element> { ... private class CompoundIndexIterator extends CompoundIterator<IndexIterator<Element>> implements IndexIterator<Element> { ... } } The error is: type parameter diergo.collect.IndexIterator<Element> is not within its bound extends CompoundIterator<IndexIterator<Element>> ^ What is wrong? The code compiles with eclipse, but bot with java 5 compiler (I use ant with java 5 on a mac and eclipse 3.5). No, I cannot convert it to a static inner class.

    Read the article

  • CSS inheritance, aliases and other cool stuff

    - by emzero
    The other day I was randomly browsing the web and I found some program that lets you write CSS aliases and other cool stuff (which I can't remember right now). As an example, I remember you can do something like this: .myclass { background-color: red; greenfont } where greenfont was defined somewhere else as somekind of alias greenfont { color: green; } Then the program will generate the resulting CSS based on the alias and other stuff. Does anyone has used this? Or did I dreamed about it? I cannot find it now :P

    Read the article

  • Help a Python newbie with a Django model inheritance problem

    - by Joshmaker
    I'm working on my first real Django project after years of PHP programming, and I am running into a problem with my models. First, I noticed that I was copying and pasting code between the models, and being a diligent OO programmer I decided to make a parent class that the other models could inherit from: class Common(model.Model): self.name = models.CharField(max_length=255) date_created = models.DateTimeField(auto_now_add=True) date_modified = models.DateTimeField(auto_now=True) def __unicode__(self): return self.name class Meta: abstract=True So far so good. Now all my other models extend "Common" and have names and dates like I want. However, I have a class for "Categories" were the name has to be unique. I assume there should be a relatively simple way for me to access the name attribute from Common and make it unique. However, the different methods I have tried to use have all failed. For example: class Category(Common): def __init__(self, *args, **kwargs): self.name.unique=True Spits up the error "Caught an exception while rendering: 'Category' object has no attribute 'name' Can someone point me in the right direction?

    Read the article

  • ActiveRecord table inheritence using set_table_names

    - by Jinyoung Kim
    Hi, I'm using ActiveRecord in Ruby on Rails. I have a table named documents(Document class) and I want to have another table data_documents(DataDocument) class which is effectively the same except for having different table name. In other words, I want two tables with the same behavior except for table name. class DataDocument < Document #set_table_name "data_documents" self.table_name = "data_documents" end My solution was to use class inheritance as above, yet this resulted in inconsistent SQL statement for create operation where there are both 'documents' table and 'data_documents' table. Can you figure out why and how I can make it work? >> DataDocument.create(:did=>"dd") ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'data_documents.did' in 'where clause': SELECT `documents`.id FROM `documents` WHERE (`data_documents`.`did` = BINARY 'dd') LIMIT 1 from /Users/lifidea/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log' from /Users/lifidea/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute' from /Users/lifidea/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:595:in `select' from /Users/lifidea/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache' from /Users/lifidea/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'

    Read the article

  • Multi-level inheritance with Implements on properties in VB.NET vs C#

    - by Ben McCormack
    Let's say I have 2 interfaces defined like so: public interface ISkuItem { public string SKU { get; set; } } public interface ICartItem : ISkuItem { public int Quantity { get; set; } public bool IsDiscountable { get; set; } } When I go to implement the interface in C#, VS produces the following templated code: public class CartItem : ICartItem { #region ICartItem Members public int Quantity { get {...} set {...} } public bool IsDiscountable { get {...} set {...} } #endregion #region ISkuItem Members public string SKU { get {...} set {...} } #endregion } In VB.NET, the same class is built out like so: Public Class CartItem Implements ICartItem Public Property IsDiscountable As Boolean Implements ICartItem.IsDiscountable 'GET SET' End Property Public Property Quantity As Integer Implements ICartItem.Quantity 'GET SET' End Property Public Property SKU As String Implements ISkuItem.SKU 'GET SET' End Property End Class VB.NET explicitly requires you to add Implements IInterfaceName.PropertyName after each property that gets implemented whereas C# simply uses regions to indicate which properties and methods belong to the interface. Interestingly in VB.NET, on the SKU property, I can specify either Implements ISkuItem.SKU or Implements ICartItem.SKU. Although the template built by VS defaults to ISkuItem, I can also specify ICartItem if I want. Oddly, because C# only uses regions to block out inherited properties, it seems that I can't explicitly specify the implementing interface of SKU in C# like I can in VB.NET. My question is: Is there any importance behind being able to specify one interface or another to implement properites in VB.NET, and if so, is there a way to mimic this functionality in C#?

    Read the article

  • VB.NET, templates, reflection, inheritance, feeling adrift

    - by brovar
    I've just made myself up a problem and am now wondering how to solve it. To begin with, I'm using some third-party components, including some calendar controls like schedule and timeline. They're used in the project classes more or less like that: Friend Class TimeBasedDataView 'some members End Class Friend Class ScheduleDataView Inherits TimeBasedDataView Public Schedule As Controls.Schedule.Schedule 'and others End Class Friend Class TimeLineDataView Inherits TimeBasedDataView Public TimeLine As Controls.TimeLine.TimeLine 'and others End Class (Hmm, code coloring fail, never mind...) Now, to allow managing the look of data being presented there are some mechanisms including so called Style Managers. A lot of code in them repeats, varying almost only with the control it maintains: Friend Class TimeLineStyleManager Private m_TimeLine As TimeLineDataView Private Sub Whatever() m_TimeLine.TimeLine.SomeProperty = SomeValue End Sub End Class Friend Class ScheduleStyleManager Private m_Schedule As ScheduleDataView Private Sub Whatever() m_Schedule.Schedule.SomeProperty = SomeValue End Sub End Class I was wondering if I could create some base class for those managers, like Friend Class TimeBasedCtrlStyleManagerBase(Of T As TimeBasedDataView) Private m_Control As T 'and others End Class which would unify these two, but I've got lost when it came to maintaining two components that have nothing in common (except their properties' names, etc.). Type reflection maybe? I'll be grateful for any advice ;)

    Read the article

  • Java inheritance question

    - by Milos
    I have an abstract class Airplane, and two classes PassengerAirplane and CargoAirplane, which extend class Airplane. I also have an interface Measurable, and two classes that implement it - People and Containers. So, Airplane can do many things on its own, and there is a method which allows measurable things to be added to the airplane (called addAMeasurableThing). The only difference between PassengerAirplane/CargoAirplane and just an Airplane is that addAMeasurableThing should only accept People / Containers, and not any kind Measurable things. How do I implement this? I tried doing: Airplane class: public abstract Airplane addAMeasurableThing (Measurable m, int position); PassengerAirplane class: public Airplane addAMeasurableThing (Measurable m, int position) { if (m instanceof People)... CargoAirplane class: public Airplane addAMeasurableThing (Measurable m, int position) { if (m instanceof Containers)... But when I was debugging it, I've noticed that addAMeasurableThing in the CargoAirplane class never gets called, because both methods have the same signature. So how can the appropriate PassengerAirplane/CargoAirplane's addAMeasurableThing be called, depending on the type of Measurable thing that is being passed on? Thanks!

    Read the article

  • C# inheritance of fields

    - by Emil D
    This is probably a silly question, but here it goes.Imagine you have the following classes: public class C { } public class D : C { //A subclass of C } public class A { C argument; } Now, I want to have a class B, that inherits from A.This class would obviously inherit the "argument" field, but I wish to force the "argument" field in B to be of type D, rather than C.Since D inherits from C this shouldn't create any problems. So, how would achieve this in c# ?

    Read the article

  • How to convert EER to SQL Table?

    - by Khajavi
    I have no problem with converting ER to SQL tables, but I don't know how can I convert EER to SQL tables? as you Know that EER has "is a" specification and inheritance, but I don't know how relational databases can connect with inheritance specification

    Read the article

  • Multiple Table Inheritance vs. Single Table Inheritance in Ruby on Rails

    - by Tony
    I have been struggling for the past few hours thinking about which route I should go. I have a Notification model. Up until now I have used a notification_type column to manage the types but I think it will be better to create separate classes for the types of notifications as they behave differently. Right now, there are 3 ways notifications can get sent out: SMS, Twitter, Email Each notification would have: id subject message valediction sent_people_count deliver_by geotarget event_id list_id processed_at deleted_at created_at updated_at Seems like STI is a good candidate right? Of course Twitter/SMS won't have a subject and Twitter won't have a sent_people_count, valediction. I would say in this case they share most of their fields. However what if I add a "reply_to" field for twitter and a boolean for DM? My point here is that right now STI makes sense but is this a case where I may be kicking myself in the future for not just starting with MTI? To further complicate things, I want a Newsletter model which is sort of a notification but the difference is that it won't use event_id or deliver_by. I could see all subclasses of notification using about 2/3 of the notification base class fields. Is STI a no-brainer, or should I use MTI? Thanks!

    Read the article

  • Delphi 7 inheritance

    - by Gene
    Have 6 forms, 1 Base and 5 inherited.The Base has the following snippet: procedure TMechan.Open1Click(Sender: TObject); begin if OpenDialog1.Execute then Form1.Memo1.Lines.LoadFromFile(OpenDialog1.FileName ); CopyCylMemoToRecord;ShowMechanicalValues; end; Since this snippet is in the Base it's also inherited by 5 others. Problem is: When executing OpenDialog the Base is overwritten instead of the inherited form. HELP

    Read the article

  • Visual ++ print from main with inheritance on visual form in listbox

    - by captencrunch
    I´ve made a "main" class lets call it A(Veichle), and i have two classes that inherits from A Lets call them B(Car) and C(MC). i also have a handler lets call it "D" that binds A,B and C. Then i have the Form1 class lets call that E(Visual) I want to print out the private members from A on the visual form "E" in a Listbox If i try ex) this-listbox1-items-add(X.veichles[i]-getBrand()); it complains that veichles is a private member in D. How can i get around that?

    Read the article

  • Dynamic inheritance/implementation in PHP 5.*

    - by Rolf
    Hi everyone, I'm implementing a Logger, based on a XML declaration (path to class, method name, custom log message). There is also a Logger interface that defines the function __call, the latter logs what's needed and then relays the call to the target method. The only difficulty is to make each class, declared in the XML file, implement this interface with __call. So finally my question: is there a way to set at runtime the parent class or the implemented interface of another class ? Thanks in advance ! Rolf

    Read the article

  • Inheritance Problem in Perl OOP

    - by Sam
    Hello, I have a sub class that calls a method from a super class. and the method in the super class use a method that is defined in the super class as asbstract(not really abstract) but implemented in the sub class. for example: package BaseClass; sub new { } sub method1 { return someAbstractMethod(); } sub someAbtsractMethod { die "oops, this is an abstract method that should be implemented in a subclass" ; } 1; package SubClass; sub new { } sub someAbtsractMethod { print "now we implement the asbtract method"; } 1; now when I do: $sub = new SubClass(); $sub-method1(); It calls the abstract message and i get the specified error message. if I took off the abstractmethod from the super class and just leave the implementation in the subclass, It does not recognize the method and I get subroutine abstractmethod not found error.

    Read the article

  • WPF Window Inheritance

    - by Jonathan Sternberg
    I have an application that will run in two modes, each with very similar displays. The application is supposed to allow easy modification of a user interface. One of the features is that it has to display the user interface. Both of these windows look the same, just one has more menus than the other. I'd like to just create a base template (the user visual) and then inherit it for the editor. That way if one interface changes, both of them change. But this doesn't seem to be possible using WPF. I try to inherit and I get warnings about hiding members. I also don't see how I'm going to append new menus to the base template. Is what I'm trying to do possible? Is there a better way that I'm supposed to be doing this? It seems like I'm fighting the way that they want me to make the application.

    Read the article

  • inheritance from str or int

    - by wiso
    Why I have problem creating a class the inherite from str (or also int) class C(str): def __init__(self, a, b): str.__init__(self,a) self.b = b C("a", "B") TypeError: str() takes at most 1 argument (2 given) tha same appened if I try to use int instead of str, but it works with custom classes. I need to use __new__ instead of __init__? why?

    Read the article

  • Question regarding inheritance in wxWidgets.

    - by celestialorb
    Currently I'm attempting to write my own wxObject, and I would like for the class to be based off of the wxTextCtrl class. Currently this is what I have: class CommandTextCtrl : public wxTextCtrl { public: void OnKey(wxKeyEvent& event); private: DECLARE_EVENT_TABLE() }; Then later on I have this line of code, which is doesn't like: CommandTextCtrl *ctrl = new CommandTextCtrl(panel, wxID_ANY, *placeholder, *origin, *size); ...and when I attempt to compile the program I receive this error: error: no matching function for call to ‘CommandTextCtrl::CommandTextCtrl(wxPanel*&, <anonymous enum>, const wxString&, const wxPoint&, const wxSize&)’ It seems that it doesn't inherit the constructor method with wxTextCtrl. Does anyone happen to know why it doesn't inherit the constructor? Thanks in advance for any help!

    Read the article

  • Question about design (inheritance, polymorphism)

    - by Dan
    Hi, I have a question about a problem I'm struggling with. Hope you can bear with me. Imagine I have an Object class representing the base class of a hierarchy of physical objects. Later I inherit from it to create an Object1D, Object2D and Object3D classes. Each of these derived classes will have some specific methods and attributes. For example, the 3d object might have functionality to download a 3d model to be used by a renderer. So I'd have something like this: class Object {}; class Object1D : public Object { Point mPos; }; class Object2D : public Object { ... }; class Object3D : public Object { Model mModel; }; Now I'd have a separate class called Renderer, which simply takes an Object as argument and well, renders it :-) In a similar way, I'd like to support different kinds of renderers. For instance, I could have a default one that every object could rely on, and then provide other specific renderers for some kind of objects: class Renderer {}; // Default one class Renderer3D : public Renderer {}; And here comes my problem. A renderer class needs to get an Object as an argument, for example in the constructor in order to retrieve whatever data it needs to render the object. So far so good. But a Renderer3D would need to get an Object3D argument, in order to get not only the basic attributes but also the specific attributes of a 3d object. Constructors would look like this: CRenderer(Object& object); CRenderer3D(Object3D& object); Now how do I specify this in a generic way? Or better yet, is there a better way to design this? I know I could rely on RTTI or similar but I'd like to avoid this if possible as I feel there is probably a better way to deal with this. Thanks in advance!

    Read the article

  • Vectors of Pointers, inheritance

    - by user308553
    Hi I am a C++ beginner just encountered a problem I don't know how to fix I have two class, this is the header file: class A { public: int i; A(int a); }; class B: public A { public: string str; B(int a, string b); }; then I want to create a vector in main which store either class A or class B vector<A*> vec; A objectOne(1); B objectTwo(2, "hi"); vec.push_back(&objectOne); vec.push_back(&objectTwo); cout << vec.at(1)->i; //this is fine cout << vec.at(1)->str; //ERROR here I am really confused, I checked sites and stuff but I just don't know how to fix it, please help thanks in advance

    Read the article

  • inheritance and hidden overloads

    - by Caspin
    The following code doesn't compile. struct A {}; struct B {}; class Base { public: virtual void method( A param ) { } virtual void method( B param ) = 0; }; class Derived : public Base { public: //using Base::method; void method( B param ) { } }; int main() { Derived derived; derived.method(A()); } The compiler can't find the overload of method() that has an A parameter. The 'fix' is to add a using declaration in the derived class. My question is why. What is the rational for a weird language rule like this? I verified the error in both GCC and Comeau, so I assume this isn't a compiler bug but a feature of the language. Comeau at least gives me this warning: "ComeauTest.c", line 10: warning: overloaded virtual function "Base::method" is only partially overridden in class "Derived" class Derived : public Base ^

    Read the article

  • django templating system inheritance issue

    - by Suhail
    hi, i am having issues with my django templating system, i have a base.html file, which contains the content which will be common on all the web pages of the web site, the base.html file fetches some dynamic content, like the categories and the archives, which are passed to it by a python file, which fetches the categories and the archives data from a mysql database. the issue when i inherit this base.html file in other html files like index.html: {% extends "base.html" %} and when when i call the main index URL for ex: http://mywebsite.com/index/ the index page gets loaded, but the categories and the archives data that should get loaded from the base.html file does not. what am i doing wrong, please help.

    Read the article

  • Inheritance in Java

    - by stevebot
    If I have an abstract class in java named Foo and it has an implementor named Bar then I want to know the following. lets say Foo looks something like public abstract class Foo { Service serviceFoo ... } And Bar is public class Bar extends Foo { ... } Also, lets assume I have an instance with Foo, named foo, currently that has serviceFoo instantiated If I then declare: Foo foo = new Bar(); will this create a a new instance of Bar that has serviceFoo instantiated or not? E.g. will that field be inherited and instantiated or just inherited?

    Read the article

  • C++ Class Inheritance architecture - preventing casting

    - by Some One
    I have a structure of base class and a couple of inherited classed. Base class should be pure virtual class, it should prevent instantiation. Inherited classes can be instantiated. Code example below: class BaseClass { public: BaseClass(void); virtual ~BaseClass(void) = 0; }; class InheritedClass : public BaseClass { public: InheritedClass1(void); ~InheritedClass1(void); }; class DifferentInheritedClass : public BaseClass { public: DifferentInheritedClass(void); ~DifferentInheritedClass(void); }; I want to prevent the following operations to happen: InheritedClass *inherited1 = new InheritedClass(); DifferentInheritedClass *inherited2 = new DifferentInheritedClass (); BaseClass *base_1 = inherited1; BaseClass *base_2 = inherited2; *base_1 = *base_2;

    Read the article

  • c# multi inheritance

    - by user326839
    So ive got a base class which requires a Socket: class Sock { public Socket s; public Sock(Socket s) { this.s = s; } public virtual void Process(byte[] data) { } ... } then ive got another class. if a new socket gets accepted a new instance of this class will be created: class Game : Sock { public Random Random = new Random(); public Timerr Timers; public Test Test; public Game(Socket s) : base(s) { } public static void ReceiveNewSocket(object s) { Game Client = new Game((Socket)s); Client.Start(); } public override void Process(byte[] buf) { Timers = new Timerr(s); Test = new Test(s); Test.T(); } } in the Sock class ive got a virtual function that gets overwritten by the Game class.(Process function) in this function im calling a function from the Test Class(Test+ Timerr Class: class Test : Game { public Test(Socket s) : base(s) { } public void T() { Console.WriteLine(Random.Next(0, 10)); Timers.Start(); } } class Timerr : Game { public Timerr(Socket s) : base(s) { } public void Start() { Console.WriteLine("test"); } } ) So in the Process function im calling a function in Test. And in this function(T) i need to call a function from the Timerr Class.But the problem is its always NULL , although the constructor is called in Process. And e.g. the Random Class can be called, i guess its because its defined with the constructor.: public Random Random = new Random(); and thats why the other classes(without a constructor): public Timerr Timers; public Test Test; are always null in the inherited class Test.But its essentiel that i call other Methods of other classes in this function.How could i solve that?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >