“Object” does not contain a definition for “name”

后端 未结 6 2032
误落风尘
误落风尘 2021-01-28 21:39

I\'m having an error message that tells me this:

\'BankAccount.account\' does not contain a definition for \'withdraw\'.

Here\'s my code:

using S         


        
6条回答
  •  我在风中等你
    2021-01-28 22:14

    If you look closely, you'll see that your account class in fact doesn't have a withdraw method.

    I'd guess you meant to have your account class contain a virtual method withdraw, defined like this: public virtual void withdraw(float amt) { ... }

    Then, in your inherited classes you'd want to override this method, like so:

    class currentaccount : account
    {
        public override void withdraw(float amt)
        {
            ...
            base.withdraw(amt)
            ...
        }
        ...
    }
    

    There's also a naming style issue with your code, but this is probably not in the scope of this question :)

提交回复
热议问题