Exemple #1
0
def test_constructor():
    p1 = Point(10, 20)  # __init__ 수행
    print("x={}, y={}, count_of_instance={}".format(p1.x, p1.y, Point.get_count_of_instance()))
    p2 = Point(100, 200)
    print("x={}, y={}, count_of_instance={}".format(p2.x, p2.y, Point.get_count_of_instance()))

    del p1 # __del__ 소멸자 수행
    print("count_of_instace = {}".format(Point.get_count_of_instance()))
Exemple #2
0
def test_construcotr():
    p1 = Point(10, 20)
    print("x={}, y= {}, count_ofinstance= {}".format(
        p1.x, p1.y, Point.get_count_of_instance()))
    p2 = Point(30, 40)
    print("x={}, y= {}, count_ofinstance= {}".format(
        p2.x, p2.y, Point.get_count_of_instance()))

    del p1  # __del__ 소멸자 수행

    print("count_ofinstance= {}".format(Point.get_count_of_instance()))
Exemple #3
0
def test_other_methods():
    # static, class 멤버에 접근
    print("참조 카운트:", Point.get_count_of_instance())
    Point.static_method()
Exemple #4
0
def test_other_method():
    #static, class멤버에 접근하기
    print("참조 카운트: ", Point.get_count_of_instance())    #get_count_of_instance에는 cls인자가 있고, Point클래스를 받기 때문에 따로 적어주지 않아도 된다.
    Point.static_method()