base

Prevent calling base class implemented interface method in the derived class C#

北慕城南 提交于 2020-01-13 20:34:06
问题 Is it possible to implement an interface in a base class and allow calling/overriding the implemented method in the first derived class level but prevent calling it from any further derived classes? public interface IInterfaceSample { bool Test(); } public class Base: IInterfaceSample { public virtual bool Test() { return True; } } public class Sub1: Base { //I need to be able to override the Test method here public override bool Test() { return True; } } //Under a separate project: public

关于java继承的哪些事

青春壹個敷衍的年華 提交于 2020-01-13 03:52:29
引言 本文结合一个例子来说明继承实现的基本原理。 基类 Base 代码如下所示: public class Base { public static int s; private int a; static { System.out.println("基类静态代码块,s:"+s); s=1; } { System.out.println("基类实例代码块,a:"+a); a=1; } public Base(){ System.out.println("基类构造方法,a:"+a); a=2; } protected void step(){ System.out.println("base s:"+s+",a:"+a); } public void action(){ System.out.println("start"); step(); System.out.println("end"); } } 注意: Base 包含一个静态变量s,一个实例变量a,一段静态初始化代码块,一段实例初始化代码块,一个构造方法,两个方法step和action。 子类 Child 代码如下所示: public class Child extends Base{ public static int s; private int a; static { System.out.println(

AvalonDock 2.0+Caliburn.Micro+MahApps.Metro实现Metro风格插件式系统(菜单篇)

不想你离开。 提交于 2020-01-11 15:56:52
这章主要说插件的菜单,可以说菜单是最核心的部分,前面我们已经实现了Document添加,现在主要就是生成具有层级关系的菜单,以及把菜单跟我们自定义的Document关联起来,也就是MenuPart->View->Model的关联,菜单的实现部分我也是网上参照别人的来实现的,由于代码比较多,我就抽一些重要的来说,其他的只能靠各位自己去体会了,不明白的可以照葫芦画瓢,这菜单部分可以直接抽出来用的,我们不需要明白它内部是怎么实现的,能用就行了,其实有些地方我也没有深入去了解,我们主要的任务是把现有的技术融合成一个可用的插件平台,技术的细节以后有时间再讨论。。。   额外提示所有关于UI的操作都是以绑定的方式实现的,如果不熟悉WPF以及MVVM模式可能会难以理解 [BY Zengg] 运行结果:   可以看到我们已经能做到通过菜单来控制插件的显示以及关闭,插件平台已经初具雏形 UICore部分 涉及到核心的项目结构部分: IPart 定义了菜单的基本属性,主要的方法是 void Execute(),这是单击菜单后的执行方法, 之后我们得把Show出Document的动作写入Execute方法里面。 1 namespace UICoreFramework 2 { 3 /// <summary> 4 /// Denotes an instance which can be executed.

R: rownames, colnames, dimnames and names in apply

随声附和 提交于 2020-01-10 19:36:10
问题 I would like to use apply to run across the rows of a matrix, and I would like to use the rowname of the current row in my function. It seems you can't use rownames , colnames , dimnames or names directly inside the function. I am aware that I can probably create a workaround based on information in this question. But my question is how does apply handle row and column names of the array in it's first argument, and the assignment of names to objects created inside the function called by apply

17_安装部署Tomcat服务器、使用Tomcat部署虚拟主机、使用Varnish加速Web

狂风中的少年 提交于 2020-01-08 00:42:59
1.安装部署Tomcat服务器 官网:https://tomcat.apache.org/ proxy 10.10.11.10 client 10.10.11.11 web1 10.10.11.12 web2 10.10.11.13 web1: 1.1 使用RPM安装JDK环境 ]# yum -y install java-1.8.0-openjdk ]# yum -y install java-1.8.0-openjdk-headless ]# java -version # 查看JAVA版本 openjdk version "1.8.0_222-ea" OpenJDK Runtime Environment (build 1.8.0_222-ea-b03) OpenJDK 64-Bit Server VM (build 25.222-b03, mixed mode) 1.2 安装apache-tomcat-9.0.30软件包 ]# mv apache-tomcat-9.0.30 /usr/local/tomcat ]# ls /usr/local/tomcat bin/ # 主程序目录 lib/ # 库文件目录 logs/ # 日志目录 temp/ # 临时目录 work/ # 自动编译目录jsp代码转换servlet conf/ # 配置文件目录 webapps/ # /

html5

只谈情不闲聊 提交于 2020-01-07 02:56:43
由于遗留问题,DOCTYPE是必须有的。若没有DOCTYPE,浏览器可能会选择一些不兼容的渲染模式。DOCTYPE可写为以下三种方式之一。 <!DOCTYPE html> <!DOCTYPE html SYSTEM "about:legacy-compat"> <!DOCTYPE html SYSTEM 'about:legacy-compat'> 元素分6种。虚元素、模板元素、原始文本元素、可转义的原始文本元素、外来元素和普通元素。 html元素 p150 代表HTML文档的根。最好加上lang属性来指定文档语言,以有助于语音合成工具选择发音,以及翻译工具选择翻译规则。lang属性 p138 指示了元素内容中或者元素属性中包含的文本的初始语言。lang属性的值必须是一个有效的BCP47语言标签,或空字符。空字符代表未知语言。 <html lang="en"> ... </html> head元素 p151 代表HTML文档的元数据。 <head> ... </head> title元素 p152 代表HTML文档的标题或者名字。一个HTML文档最多一个title元素。 <head> <title>Introduction to HTML5</title> </head> base元素 p153 用来指定解析URLs时所需的基础URL。或者用来设置后续超链接的默认浏览上下文

Seeing what class an object is

主宰稳场 提交于 2020-01-06 13:12:09
问题 If I have a pointer to a base class A in C++, how would I be able to tell in my code that the pointer is to a derived class B or C ? 回答1: Assuming the base class A is polymorphic (i.e. it has at least one virtual function), you can use dynamic_cast . Given an A* ap; : if (B* bp = dynamic_cast<B*>(ap)) { // the object is a B } else if (C* cp = dynamic_cast<C*>(ap)) { // the object is a C } 回答2: You generally shouldn't need to know: struct A { virtual int generate_foo() = 0; }; struct B : A {

Setting the base tag of a dynamically created iframe

别等时光非礼了梦想. 提交于 2020-01-04 04:44:07
问题 I'm trying to dynamically create an iframe and set it's base tag before it is created. ifrm = document.createElement("IFRAME"); ifrm.setAttribute("src", "test.html"); ifrm.style.width = 400+"px"; ifrm.style.height = 100+"px"; //before creating it, can we set he base tag? //I.E. <base href="http://example.com/MyFolder/" /> var bt = ifrm.contentDocument.createElement("base"); bt.setAttribute("href", "http://www.example.com/Folder/"); ifrm.contentDocument.getElementsByTagName("head")[0]

invalid literal for int() with base 10 - django - updated

谁说胖子不能爱 提交于 2020-01-03 18:35:38
问题 I am a django beginner, and I am trying to make a child-parent like combo box, (bars depends on city depends on country) and I get this error. UPDATE: Changed the model and the default value for the foreign key, but still the same error. Any help? thanks! this is models.py: from django.db import models from smart_selects.db_fields import ChainedForeignKey DEFAULT_COUNTRY_ID = 1 # id of Israel class BarName(models.Model): name = models.CharField(max_length=20) def __unicode__(self): return

c++中为什么可以通过指针或引用实现多态,而不可以通过对象呢?

ぐ巨炮叔叔 提交于 2020-01-03 17:28:41
目录 一、类对象的存储方式: 二、无论通过对象还是指针,能使用的方法只与它们静态类型有关。 三、 不同类型的指针有什么区别? 四、 指针与引用来实现多态 五、对象不能实现多态 引言: 在c++中司空见惯的事情就是:可以通过指针和引用可以实现多态,而对象不可以。 那为什么?让我们来解开这神秘的暗纱!转载自:https://www.cnblogs.com/yinheyi/p/10525543.html 一、类对象的存储方式: 在一个类的实例中,只会存放非静态的成员变量。 如果该类中存在虚函数的话,再多加一个指向虚函数列表指针—vptr。 例如声明如下两个类,并分别实例化两个对象,它们的内存分配大致如下:(vptr具体在什么位置,与编译器有关,大多数都在开始处) class base { public: virtual ~base() {}; virtual string GetName() { return "base"; } GetA(); int a; }; class derived : public base { public: virtual ~derived() {}; virtual string GetName() { return "derived";} GetB(); int b; }; base B1, B2; derived D1, D2; 内存分布大致如下: