1. 一个简单的swing public class Test(){ public static void main(String[] args){ JFrame frame = new JFrame(); JPanel panel = new JPanel(); JTextArea textArea = new JTextArea(); panel.setLayout(new GridLayout()); textArea.setText("test"); //当TextArea里的…
1. 一个简单例子: public class Test(){ public static void main(String[] args){ JFrame frame = new JFrame(); JPanel panel = new JPanel(); JTextArea textArea = new JTextArea(); panel.setLayout(new GridLayout()); textArea.setText("test"); //当TextArea里的内容过…
下面有关派生类与基类中存在同名函数 fn: class A { public: void fn() {} void fn(int a) {} }; class B : public A { public: void fn() {} }; int main() { B b; b.fn(); ; } 1.以上代码编译为什么不能通过? (问题在第21行,编译器会报怨说,B中,并不存在fn(int)的函数). 2.编译器这样做(即不允许通过这样的代码)的好处是什么? 相信这是一个非常之普遍的问题了,在众…