135 Topics

Member Avatar for
Member Avatar for cwpent

I'm doing a lesson that is supposed to demonstrate inheritance using the song Old MacDonald; there's an animal interface, a farm class that implements each animal object.. you get the idea. I've got two problems. First, The animal has a type and a sound, for example, a chick is [code] …

Member Avatar for joankim
0
1K
Member Avatar for enkitosh

Hi. I'm making a shooting game and since my code was getting a bit messy and big I decided to divide it into couple of classes and files. I'm confused of how to correctly split these files and classes up though. As I imagine it without really knowing if that …

Member Avatar for Serapth
0
360
Member Avatar for greatman05

So, I'm a bit confused with how inheritance works in relation to variables. Let's say that I had the following class: class Test { private: int var1; float var2; public: void getInfo(int,float); void setStuff(int,float); }; Now, let's suppose that I wanted to derive a class from that base class; I …

Member Avatar for Ancient Dragon
0
206
Member Avatar for wonderlandslost

So my instructor assigned us to create a program that calculates the area and stores that, along with coordinates, in an array. This has to be done for both triangles and squares. He is having us use separate classes for the project; the main Drawer class, parent class, square class, …

Member Avatar for wonderlandslost
0
299
Member Avatar for Kanoisa

Hi all, I have started finding lots of uses for abstract classes to define interfaces for common functionality using polymorphism and i know that using polymorphism and virtual functions incurrs some additional call cost of functions. So what im wondering is can i get the best of both worlds? consider …

Member Avatar for Kanoisa
0
192
Member Avatar for badboy11

Need help with implementing a pure abstract class via inheritance, using namespace to wrap all my classes to avoid conflict with others. I have been able to build and run the code successfully if I remove namespace wrapper from my abstract class and all classes that inherit from my pure …

Member Avatar for badboy11
0
253
Member Avatar for swy

I'm trying to read in the following text file: Jim Nasium mgr Fitness & Leisure 45000 Lazy Susan mgr Home Furnishings 55000 Gene Theory mgr Fine Jewelry 10000 And I have the following code: public abstract class Employee { private String name; private double grossPay; private double netPay; private final …

Member Avatar for NormR1
0
214
Member Avatar for 3nrichedd

I am working on this assignment in my java class, and am running into a few problems. Basically there are 2 classes and a main/client program that tests the classes. there is 1 superclass and a subclass that extends the superclass.. I have 2 constructors in my superclass but when …

Member Avatar for hiddepolen
0
250
Member Avatar for connect2abhi

Hi Can any one tell me how to call a subclass method from a superclass? For example: I have a class A,B and C. Now B and C extends A. So is there any way that we can call a method of B in A? Thanks Abhishek

Member Avatar for DavidKroukamp
0
12K
Member Avatar for Labdabeta

I have a function that takes a reference to an interface class as a parameter. I have created a derived class from the interface class, but when I try to call the function with an instance of my derived class as an argument I get a compiler error saying "error: …

Member Avatar for Labdabeta
0
144
Member Avatar for Labdabeta

I have been teaching myself algorithms and I am stuck with the AlphaBeta AI algorithm. I want to test my knowledge of it with a TicTacToe simulation. The thing is I want it to be easy to modify for any two player game and I cannot figure out how to …

Member Avatar for Labdabeta
0
164
Member Avatar for epicbeast9022

Hello everybody I [I]thought[/I] I understood inheritance but it turns out I don't. I am creating an SDL/OpenGL mini-GUI library. I have a master class, GUIComponent, with subclasses such as TextLabel under it. I have a vector called guiList that is initialized as [ICODE]std::vector<GUIUnit*> guiList[/ICODE] (it's extern'd and initialized elsewhere; …

Member Avatar for vijayan121
0
172
Member Avatar for Dman01

Hi community First I want to thank everyone who will look through this, because it's a longer post. I'm currently reading a book on AI by Mat Buckland. I'm re-building Mats entitymanager, though I just copied it. He used std::map to collect all entities as pointers which are cross referenced …

Member Avatar for Dman01
0
2K
Member Avatar for JwhateverJ

I'm writing an application launcher program. The launcher will launch applications based on the files found in the working directory. (Example: a folder containing files with the extensions .docx, .xlsx, .sln, and .txt, would give the user the option to launch Word, Excel, Visual Studio and Notepad loading any of …

Member Avatar for cox44
0
905
Member Avatar for metronomu

A question regarding inheritance implementation. Let's say we have 2 classes: [CODE]class B { public: int x; // for the sake of argument it's public, don't stone me }; class D: public B { public: int x; // again x, i know ... stupid dilemma };[/CODE] Now, if you will …

Member Avatar for metronomu
0
136
Member Avatar for nikitadurgude

[CODE]#include <iostream> using namespace std; class bike { public: bike () { cout << "Bike: no parameters\n"; } bike (int a) { cout << "Bike: int parameter\n"; } void color(int a,int b) { cout<<"Inside Bike Color"<<endl; } }; class ducati : public bike { public: ducati (int a) { cout …

Member Avatar for Narue
0
210
Member Avatar for powerdink

Hello all, I'm trying to inherit a "CarPanel" I created using arrays to draw various shapes in order to make a car. Now I am trying to essentially create a subclass that inherits that class, but add a Timer Action to move the car across the screen. I got it …

Member Avatar for JamesCherrill
0
500
Member Avatar for AT--O

[CODE] Public Class aaMyForm Inherits Windows.Forms.Form [/CODE] Added some controls. Build it, add the .DLL as reference to my other project. In my other project: [CODE] Imports MyLib Public Class XForm Inherits aaMyForm [/CODE] The events from aaMyForm execute correctly but the controls added to it are not shown on …

Member Avatar for AT--O
0
118
Member Avatar for Aviras

Dear Daniwebbers, I have a problem regarding the calling of methods on a protected parent object from within a child object, the protected parent object being a child object of the same class. I have a class HostileArea, wich has a "protected DungeonRoom[][] dungeon", DungeonRoom being a child of HostileArea. …

Member Avatar for JamesCherrill
0
216
Member Avatar for MattJones

Hey Guys, I'm working on a C++ program for school. Basically the Program inputs a file of points and outputs an svg file that contains the Graph with the least number of edges. We need to implement this with the Kruskal and Prim algorithm, and the algorithm needs to be …

Member Avatar for Fbody
0
201
Member Avatar for mikesowerbutts

Hi, Im trying to convert my UserControls to be sharable across multiple projects. I have read up on this, and it seems that I need to have all code in one file (i.e. in the .ascx, rather than codebehind/designer) so I am trying to do this: [CODE] <%@ Control Language="C#" …

Member Avatar for kvprajapati
0
919
Member Avatar for davy_yg

I have the following codes: [CODE] <?php class LongName { var $firstname = " "; var $middlename = " "; var $lastname = " "; function firstname() { echo "First Name : ". $this -> firstname; } function middlename() { if (middlename){ echo "Middle Name : ". $this -> middlename; …

Member Avatar for cwarn23
0
151
Member Avatar for agmolina90

Ok I am a programming student and need help with a problem, I already have most of it (so I don't need you guys to do my hw :P) but I am having problems with am, and I am not even sure if I am doing it right. [B]Problem:[/B] (The …

Member Avatar for Ezzaral
-1
10K
Member Avatar for warlord902

I am in situation like I have a class which have two different subclasses. [CODE]public class SuperClass{ String st; public String getSt(){ return st; } } class A extends SuperClass{ } class B extends SuperClass{ } [/CODE] Now I have another method that want to access the getSt inherited method …

Member Avatar for javaAddict
0
176
Member Avatar for termin8tor

Hey all, I've been programming an ISBN system of sorts and I'm a little stuck (again). I want to output my linked list to a text file, so I setup the code like this: [code] void saveList(char fileName[40]) { for ( list< Publication* >::iterator it = pubList.begin(); it != pubList.end(); …

Member Avatar for termin8tor
0
262
Member Avatar for termin8tor

Hey all, I'm attempting to use an STL List to store a list of objects. Now I realise it's quite trivial to store a list of objects of my own definition. My real question is, how do I fill the list with objects that inherit from a base class. E.g. …

Member Avatar for termin8tor
0
267
Member Avatar for aman rathi

The below code is showing error i checked lots of time didn't find any error please help me. [CODE] class emp{ int id,sal; String name; emp(int id,int sal,String name) { this.id=id; this.sal=sal; this.name=name; } void show() { System.out.println("Name: "+name); System.out.println("Salary: "+sal); System.out.println("ID: "+id); } } class manager extends emp{ int …

Member Avatar for aman rathi
0
192
Member Avatar for iThaos

Hi, I was wondering whether it is possible to use a parent class' properties without calling its constructor. In the following example: [CODE]<?php class Shop { public $location; public function __construct($location = ''){ if(!empty($location)){ $this->location = $location; } else { $this->location = 'a place far far away'; } $this->location .= …

Member Avatar for iThaos
0
211
Member Avatar for kishanillur

I am writing some application for Android. Here my app receives sms and as soon as it receives, it launches another activity,say a browser with some url supplied. So here, I need two classes, broadcastReceiver( to receive sms) and Activity. But in java i can inherit only 2 classes. Since …

Member Avatar for JamesCherrill
0
231
Member Avatar for jackmaverick1

Hi! I've been making a rather large (but not huge, by any means) program and it needs, or so I think, a couple of classes and I want them to use inheritance to make my life easier. However, when I try to include all of my files in the main …

Member Avatar for jackmaverick1
0
217

The End.