我想在父类中创建一个函数,该函数引用哪个子类最终调用它以便获取子类中的静态变量。 这是我的代码。 class Element:
attributes = []
def attributes_to_string():
# do some stuff
return ' | '.join(__class__.attributes) # <== This is w
我有几类具有共同的祖先,每一个静态数组属性: class Foo extends Base {
static ary = [];
}
class Bar extends Base {
static ary = [];
}
而且由于ary修饰选自Base内完全处理,我还希望数组定义移入Base。 但是,当我在我的代码更改为: class Base {
sta
我是C#和OOP的初学者。 在这里,我总结了两个来自C#中外部函数的静态变量,感觉很有趣。 这是我的代码。 using System;
namespace StaticFun
{
class StaticFun
{
public static int a;
public static int b;
public void count(