前言
python中进行面向对象编程,当在子类的实例中调用父类的属性时,由于子类的__init__方法重写了父类的__init__方法,如果在子类中这些属性未经过初始化,使用时就会出错。
例如以下的代码:
class A(object):
def __init__(self):
self.a = 5
def function_a(self):
print('I am from A, my value is %d' % self.a)
class B(A):
def __init_
一,抽象的实现
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Virtualdemo
{
class Program
{
static void Main(string[] args)
{//BClass A = new BClass(); 抽象类无法被实例
Class1 c = new Class1();