package com.test7; public class test7 { public static void main(String[] args) { Son son = new Son(1000, "张三"); /** * 打印显示 Father的构造函数1000 张三 Son的构造函数1000 张三 */ } } class Father { private int userId; private String userName; public Father(int us
<?php class a { private function fun1(){ echo 'a1'; } //protected 可以被继承,但是只能在子类中使用,不能被实例化调用 protected function fun2(){ echo 'a2'; } public function fun3(){ echo 'a3'; } } class b extends a{ public function __construct(){ $this->fun2(); } public func
java中继承,子类是否继承父类的构造函数 java继承中子类是不会继承父类的构造函数的,只是必须调用(隐式或者显式) 下面来看例子: public class TestExtends { public static void main(String[] args) { SonClass s = new SonClass(66); } } class FooClass{ public FooClass() { System.out.println(100); } public FooClass(
请看下面代码: using System; public class A{ public A(){ M1(); } public virtual void M1(){} } public class B : A{ private string _method; public B(){ _method = "B_C"; } public override void M1(){ Console.WriteLine("Type:{0}, in B, {1}",GetTyp