If I implement an abstract class that contains this method: private void MyMethod(string awesomeParameter, int aBigNumber) { // something cool happens here! throw new NotImplementedException(); } can I change it to this without breaking the implementation? private void MyMethod(string myParam, int myInt) { // something cool happens here! throw new NotImplementedException(); } I can't seem to find an answer to this, and I've never run into this issue before, but I'm implementing a new MembershipProvider and the default implementation uses some logical parameter names, but they don't match our sql table schema. For example, the implementation uses "username" but our …

Member Avatar
Member Avatar
+0 forum 3

Hello everyone. I am currently making some database connection modules in Python inb order to learn Python's approach to OOP and also to lear how to connect to databases via Python. I successfully made a package with modules for postgres, mysql, sqlite3, and MongoDB. The classes simply connect, disconnect and run queries of any type. Everything is working fine now. However I noticed that the code is nearly the same. For example, the connect and disconnect methods are exactly the same. Also, postgress and mysql connections have exactly the same number of attributes. Inheritance came to mind, but some classes …

Member Avatar
Member Avatar
+0 forum 16

Hi fellow members, I have wrote two abstract classes, with the second inheriting from the first. However, I receive this error when I try to compile: "error C2143: syntax error : missing ',' before '<'." Will somebody help me out? Thanks! template <class DataType> class AbstactArrayClass { friend ostream& operator << (ostream& s, AbstactArrayClass<DataType>& ac); public: virtual int size() const = NULL; virtual DataType& operator[] (int k) = NULL; }; template <class DataType> ostream& operator << (ostream& s, AbstactArrayClass<DataType>& ac) { s << "["; for (int i = 0; i < ac.size(); i++) { if (i > 0) { s …

Member Avatar
Member Avatar
+0 forum 1

Hello good day. Here is my problem: I have retrieved some a couple sets of data from my sql database and saved them in ArrayLists of (custom)types <Student> and <Subject>. I am using a single Table. I want to create a custom AbstractDataModel that displays the data from the ArrayList<Student>. The data that comes from ArrayList<Student> are simply Strings, and this constitutes half of the table. The other half of the table is populated by the user editing the cells via JComboBox editor. These choices are used to carry out calculations in order to populate the ArrayList<Subject>. Problem is, all …

Member Avatar
Member Avatar
+0 forum 6

Hi all, I am trying to lay out a plan for my classes, and havent godt the most experience in oop yet. I am using an abstract class, to be able to have a more clear overview and keep the project easier to manage. SO: I have created two abstract classes and extended them, so the child classes implements the desired methods. class concrete_product_views extends abstract_product_views { public function display_index_products( $ProdID ) { } public function display_product_category( $CatID, $limit = 5 ) { } public function display_product( $ProdID ) { } } NOW, inside this class I need to use …

Member Avatar
Member Avatar
+0 forum 3

I have an abstract class CArticle and two derived classes CBook and CMagazine. I also have a class CLibrary where i want to add articles. Its members are an int variable to count the articles and a double pointer of CArticle. I have the following main function: int main() { CLibrary L1; CArticle *A1=new CBook(1000); CArticle *A2=new CBook(1001); CArticle *A3=new CMagazine(1002,3); CArticle *A4=new CMagazine(1003,6); CArticle *A5=new CMagazine(1004,8); L1.addArticle(A1); L1.addArticle(A2); L1.addArticle(A3); L1.print(); } I can't figure out what type of parameter should my addArticle() function have in order to work for this main. I would like to let the compiler choose …

Member Avatar
Member Avatar
+0 forum 16

Currently I have something like this: class FileWritter{ ofstream file; public: FileWritter(string filename,A_Class a){//A_Class is class which has defined the >> and the << operators file.open(filename.c_str()); file<<a; } ~FileWritter(){ file.close(); } }; what I want is to have something like this: template <class AbstractClass> class FileWritter{ ofstream file; public: FileWritter(string fileName, AbstractClass ab){ file.open(fileName.c_str()); file<<ab; } ~FileWritter(){ file.close(); } }; in this case, the compiller shows this error: > use of class template requires template argument list my question is how can I use an template class with FileWritter?

Member Avatar
Member Avatar
+0 forum 9

So I have been working on this project for quite some time and I can't figure out why I keep getting an "Illegal Start of Expression" error. I tried moving the variables above the main method and that only returned the same error but instead of the error occuring at line 14, it occurs at the start of the next method(applet). Any help would be greatly appreciated! I'm sure it's just some stupid formatting error... package superhangman; import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.Random; public abstract class SuperHangman extends Applet implements ActionListener { public static void main(String[] args){ static …

Member Avatar
Member Avatar
+0 forum 2

For a project I'm doing for class I have to make a virtual method in a class. A subclass will inherit the virtual method and instantiate it in a separate .cpp file. The problem I'm having is that I need the class that has the virtual method to instantiate its version of the method as well as the subclass. I get an error that says "cannot instantiate an abstract class" even though it is instantiated in a .cpp. Here's my code: Subdomain.h [CODE]#pragma once #include "String.h" using namespace std; class SubdomainPart { public: SubdomainPart() {} // Sets the Address SubdomainPart(const …

Member Avatar
Member Avatar
+0 forum 1

Hello all, I have an assignment in which I need to subclass and implement an abstract method (java.io.OutputStream) to create an output stream called NumStream. The NumStream class converts digits to strings. We are given most of the code it seems and I need to only implement one area. It seems when I type System.out.println("test"); it prints it 24 times. How do I get it to compare the actual string and print out the correct words for it? [CODE]import java.io.*; public class NumStream extends OutputStream { public void write(int c) throws IOException { //What goes here? } public static void …

Member Avatar
Member Avatar
+0 forum 2

Hi all, this is a homework assignment that I'm not sure how to begin with. We are given all the code and I just need to finish a function to convert digits to words. For example, the string "1, 2, and 3." becomes "One, Two, and Three." The String "10" becomes "OneZero." We aren't allowed to use any loop constructs either ("for" or "while"). We are supposed to use the switch-case statements somehow. The missing function is the "public void append(char c)" This is what I have but I'm getting no results. [CODE]public abstract class Builder { // Appends just …

Member Avatar
Member Avatar
+0 forum 10

Writing an abstract class for homework - here's what I have so far: [CODE]public abstract class Pet { String petName; double foodAmount; double foodSupply; int days; public Pet(String petName, double foodSupply) { //constructor to be used by sub-classes this.petName = petName; this.foodSupply = foodSupply; } public Pet() {//default constructor } public void feed() { while (foodSupply>foodAmount) { foodSupply = foodSupply-foodAmount; } public abstract void eat(); public abstract void talk(); public void print() { days = (foodSupply)%(foodAmount); System.out.println(petName+" : "+days+" days left of food supply."); } public static void main(String[] args) { Pet newPet = new Pet; newPet.talk(); newPet.feed(); newPet.print(); } …

Member Avatar
Member Avatar
+0 forum 4

Hello! I'm doing my first homework assignment with abstract classes and interfaces. I have a few questions: (1) I know that a class must be saved on the computer as, for example, Class.java. Is this the same for abstract classes? How are interfaces supposed to be saved? Do they need to be in the same folder or anything as the classes that implement them? (2) I'm writing a class that simulates a bank account, including an online transfer between two accounts. To make it realistic, I'm having the class ask for the account number, amount, and purpose for the transfer, …

Member Avatar
Member Avatar
+0 forum 4

I'm working on a program for an intro to java class and am supposed to use the following interface: [CODE]public Interface Animal{ //The animal is first supposed to "speak" and then it gets to eat //As long as the food supply lasts public void feed(); //The animal eats public void eat(); //The animal "talks" public void talk(); //Print the name of the animal and then number of days //that the food will still last. public void print(); } [/CODE] The assignment says that we're supposed to write an abstract class Pet that has object variables for the names of the …

Member Avatar
Member Avatar
+0 forum 7

Hello, I need to update my older Autodesk plug-in. And I am having troubles get it through. (They changed one function) This is a new definition which I cannot change: [CODE] CoreExport virtual void EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags);[/CODE] And here is my code: [CODE] class CheckFileNames: public AssetEnumCallback { public: NameTab* missingMaps; BitmapInfo bi; CheckFileNames(NameTab* n); void RecordName(TCHAR *name); }; CheckFileNames::CheckFileNames(NameTab* n) { missingMaps = n; } int LoadMapFiles(INode* node, SContext* sc, MtlBaseLib& mtls, TimeValue t) { NameTab mapFiles; CheckFileNames checkNames(&mapFiles); // HERE is the bug //error C2259: 'CheckFileNames' : cannot instantiate abstract class node->EnumAuxFiles(checkNames, FILE_ENUM_MISSING_ONLY |FILE_ENUM_1STSUB_MISSING); } [/CODE] My …

Member Avatar
Member Avatar
+0 forum 11

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 get it to return the best next move. Can anybody give me any pointers, or maybe an idea of how to make the abstract classes that will be used by my function? I am really stuck.

Member Avatar
Member Avatar
+0 forum 2

I'm getting into some territory I have never treaded before.... What I have is an Abstract class "Person" with an abstract class "Employee" that extends "Person" and then three concrete classes within "Employee" named: Agent, Accountant, and WebDesigner. sudo: [CODE]abstract class Person{ abstract class Employee extends Person implements myInterface{ class Agent{} class Accountant{} class WebDesigner{} } class Client{} }[/CODE] What I am trying to do is in my driver class is to create an arraylist of abstract type Employee. something like this: [CODE]ArrayList<Person.Employee> employeeList = new ArrayList<Person.Employee>(); employeeList.add(new Person.Employee.agent(myStringArray));[/CODE] But I get the error "an enclosing instance that contains <my …

Member Avatar
Member Avatar
+0 forum 2

Hi I want to make an abstract method. But I always get the error " cannot declare a body because it is marked abstract." When I delete the return then I get the error than I need a return. can someone help me please [CODE] public abstract Graphics drawRectangle(Graphics drawarea) { return drawarea; } [/CODE]

Member Avatar
Member Avatar
+0 forum 2

As the title says i am trying to define RPC Calls, layers of software abstraction and serialization. I have came up with the following but confused at the last one, any help would be great Serialisation- Serialisation is the process of converting a data structure or object into a format that can be stored in a file or sent through a socket and opened again later in the same or another computer. RPC - Remote procedure calls, is a protocol that a program can use to request services from a program located in another computer in a network in a …

Member Avatar
Member Avatar
+0 forum 1

Learning about Abstract classes and interfaces, is there anything else I have forgotten about? [B]Abstract Class[/B] 1.Cannot be initated. 2.Can have concrete methods. 3.Abstract methods with no body 4.A class extending the abstract class does not need to use all the abstract methods from the abstract class. 5.A class can only extend 1 abstract class [B]Interface[/B] 1.Cannot be initated 2.Isnt a class 3.All methods must be with no body 4.A class implementing the interface must declare all methods and right a body for them whether they are used or not 5.A class can implement many interfaces.

Member Avatar
Member Avatar
+0 forum 22

Hi :) i am new in C# and i am a little confused with the abstruct, virtual and override terms in C#... why they are good for? i tried to google it but i got more confused... for example - i am making a chess program and i made a class "piece" and other classes for pawn, knight, bishop etc. that inherit from piece now, i wanna to made a "LegalSquares" function that show me all the legal squares on the board - ofcourse it will be different between the pieces what is the right way to do it? make …

Member Avatar
Member Avatar
+0 forum 1

Hey all:) I'm learning Java and I'm having a little trouble on a polymorphic write-to-file function. Let me quickly explain my project: I have an abstract class Mammal, with non-abstract children Horse, Cow etc. I have a Main program that creates a couple Horses and Cows, and store these in a Mammal array. Now the Mammal class and its children have a function called WriteData(), and the plan is that in my Main program I should be able to call this function polymorphic like array[index].WriteData(), and each Horse and Cow should write their personal info on a separate line to …

Member Avatar
Member Avatar
+0 forum 2

Im trying to to create a simple 4 function calculator using a jump table without switch case or if/else statements. I understand I can create the jump table via function pointers but I am kindda blanking out. I've started with the addition and subtraction part of the program but am trying to grasp the design/strategy to use. I am also getting an error when putting the method in the array, so far this is what i have: [CODE] public class Calculator { public abstract class Functor{ abstract double Compute(); } class Addition extends Functor { double op1, op2; public Addition(double …

Member Avatar
Member Avatar
+0 forum 6

I am trying to create an abstract data type for matrices. I have a function matrixInit to dynamically allocate memory for the structure and for the array. matrixCopy copies one matrix into another. there are functions to subtract, add and multiply matrices that return a pointer to memory where the Matrix structure is. I have included my .c file and my .h file below. I'm not exactly sure what's not working. I would appreciate it if someone could look at what I have and let me know where I'm going wrong. I believe that my first function is correct, and …

Member Avatar
Member Avatar
+0 forum 2

Ok it's all about to create 4 class Class a , class b derived from a and c derived from b and test class Speed is an instance variable in class b and c. The method are : Start() -a method of all class to print the message"hee" override the method in class b and c to print ""hoo" and "hmm" correspondingly Stop() -a method of class a to print a message"cool" override the method in class b and c to print the "stop"and "stop c" correspondingly Setspeed() -a method of class b and c to set the value of …

Member Avatar
Member Avatar
+0 forum 10

I am creating an abstract data type for strings implementing the string functions but not using the string library. I have my .c file and my .h file below. The problem seems to lie in addMystring I have commented out the area's that seem to have the problem. when they are not commented out I have a segmentation fault. though, it should work, so I believe that theres something wrong with my resizing functions, though I cannot figure out what. If someone could tell me what I am doing wrong I would appreciate it! [CODE] # include <stdio.h> # include …

Member Avatar
Member Avatar
+0 forum 7

When is it appropriate to use abstracts as opposed to interfaces to define base class behavior? What is the most common, practical usage for each? For instance, if I were to write a database applications that required to read a wide variety of database formats, would I define by database classes as abstracts or interfaces?

Member Avatar
Member Avatar
+0 forum 3

As all textbooks on C# will tell you, you cannot instantiate an abstract class. I believe the keyword [B]abstract [/B]was intended for that purpose. So can anyone tell me why I can do something like this: [CODE=c#]abstract class TwoDShape { // some code here } class test { static void Main() { TwoDShape shape = new TwoDShape(); // this gives an error TwoDShape[] shapes = new TwoDShape[4]; // this is OK } }[/CODE]

Member Avatar
Member Avatar
+0 forum 3

The End.