mike55 Posted August 11, 2006 Posted August 11, 2006 I am messing with C# at the moment, I am after creating an account class which has a balance and an account holder. It also has methods to lodge, withdraw, getbalance, and getholdersName. In the constructor section I have Account() and Account(string name, double balance) which should allow me to create a blank account or an account with existing data. I have also set the lodge and withdraw method to be overrideable. I then created a class called AdvancedAccount that inherits from Account, that has a method that overrides the account.lodge method. Everything works correctly from the main class if I go AdvancedAccount a = new AdvancedAccount(); I cannot however seem to create an account with which I can pass in the holders name and balance. Any suggestions? Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted August 11, 2006 Administrators Posted August 11, 2006 When you inherit from a class you do not inherit it's constructors - you would need to provide the relevant ones for the AdvancedAccount class; these could simply call the base classes version though. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Nerseus Posted August 12, 2006 *Experts* Posted August 12, 2006 What PD said. Here's a sample: public class AdvancedAccount(string name, double balance) : base(name, balance) { // Nothing needed here - the call to base is done above } -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.