这是在Java中使用多接口继承的示例,这是一个问题.
请注意,我完全知道为什么会出现问题,这不是我的问题.问题是关于如何命名这个特定的多接口继承歧义,如果它有一个名称.
例如,在C++中,当您使用多个实现继承并且无法确定使用哪个重写方法时出现的歧义称为"钻石问题":
http://en.wikipedia.org/wiki/Diamond_problem
再一次,我知道这不是同一个问题:那不是重点.关键是在之前的案例中创造了一个名称.
而且我想知道我将要描述的问题是否存在名称.
下面是另一种多重继承的示例,其中一个接口继承自另外两个具有不兼容方法返回类型的接口:
interface A {
void a();
Integer c();
}
interface B {
void b();
Long c();
}
interface MI extends A, B {...}
Run Code Online (Sandbox Code Playgroud)
(使用'extends'关键字注意工作中的多个接口继承)
你做不到,因为:
A型和B型不兼容; 两者都定义c()但具有不相关的返回类型
有没有一个名字来描述这种情况?
我倾向于在-dealloc中释放我的东西,现在iPhone OS 3.0引入了这个有趣的-viewDidUnload方法,他们说:
//释放主视图的所有保留子视图.//例如self.myOutlet = nil;
因此,当视图控制器的视图从内存中启动时,-viewDidUnload似乎被调用.如果我有附加到视图控制器主视图的子视图,我必须只在这里发布那些东西,但不是在-dealloc中也是如此?
这令人困惑.另外,如果-dealloc导致视图被卸载(释放),该怎么办?然后,它会调用-viewDidUnload?
我确实意识到差异,-viewDidUnload仅适用于视图本身被杀死但视图控制器保留在内存中的情况.并且-dealloc适用于整个事情进入垃圾箱的情况.
也许有人可以解决困惑.
我已经构建了我的第一个宝石,但我似乎无法正确安装它.我可以发出命令
sudo gem install ceilingfish-toto
Run Code Online (Sandbox Code Playgroud)
哪个产生输出
Successfully installed ceilingfish-toto-0.3.6
1 gem installed
Run Code Online (Sandbox Code Playgroud)
但是当我输入时gem which ceilingfish-toto.我得到了输出
Can't find ruby library file or shared library ceilingfish-toto
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为如果我去查看我的gems文件夹,我可以看到安装在那里的所有文件
# ls -l /opt/local/lib/ruby/gems/1.8/gems/ceilingfish-toto-0.3.6/
total 48
-rw-r--r-- 1 root admin 1053 14 Feb 17:16 LICENSE
-rw-r--r-- 1 root admin 6166 14 Feb 17:16 README.md
-rw-r--r-- 1 root admin 879 14 Feb 17:16 Rakefile
-rw-r--r-- 1 root admin 6 14 Feb 17:16 VERSION
-rw-r--r-- 1 root admin 2477 14 Feb 17:16 ceilingfish-toto.gemspec
drwxr-xr-x 7 …Run Code Online (Sandbox Code Playgroud) 我已经看到了两种在Python中创建无限循环的方法:
while 1:
do_something()
Run Code Online (Sandbox Code Playgroud)while True:
do_something()
Run Code Online (Sandbox Code Playgroud)这些之间有什么区别吗?比另一个更pythonic?
我正在尝试混合使用C++和Objective-C,我已经完成了大部分工作,但希望在Objective-C和C++代码之间有一个单独的接口类.因此,我想在ViewController接口中拥有一个持久的C++对象.
禁止使用没有类型的'myCppFile'声明失败:
#import <UIKit/UIKit.h>
#import "GLView.h"
#import "myCppFile.h"
@interface GLViewController : UIViewController <GLViewDelegate>
{
myCppFile cppobject;
}
@end
Run Code Online (Sandbox Code Playgroud)
但是这在.mm实现文件中运行得很好(它不起作用因为我希望cppobject在调用之间保持不变)
#import "myCppFile.h"
@implementation GLViewController
- (void)drawView:(UIView *)theView
{
myCppFile cppobject;
cppobject.draw();
}
Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法找出一个类是否是另一个类的直接基础,即在Boost类型特征术语中是一个is_direct_base_of函数.据我所知,Boost似乎不支持这种功能,这使我认为使用当前的C++标准是不可能的.
我想要的原因是对两个用于反射系统的宏进行一些验证检查,以指定一个类是从另一个派生的,如下面的示例代码所示.
header.h:
#define BASE A
#define DERIVED B
class A {};
class B : public A
{
#include <rtti.h>
};
Run Code Online (Sandbox Code Playgroud)
rtti.h:
// I want to check that the two macro's are correct with a compile time assert
Rtti<BASE, DERIVED> m_rtti;
Run Code Online (Sandbox Code Playgroud)
虽然在这个简单的例子中宏看起来是不必要的,但在我的真实场景中,情况rtti.h要复杂得多.
一种可能的途径是将this指针的大小与转换为基类型的this指针的大小进行比较,并以某种方式试图弄清楚它是否是基类本身的大小或其他东西.(是的,你是对的,我不知道那是怎么回事!)
fsc(快速scala编译器)比scalac更快.但是在TDD周期中我耗时3秒来编译源不到1秒来运行我的测试..建议减少0附近的编译时间?
显然,买一台更快的电脑不是答案:)
我的意思是使用一些scala内部来尽可能快地编译源代码
我目前在使用XHTML读取时遇到问题,因为XML解析器无法识别HTML字符实体,因此:
<?php
$text = <<<EOF
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Entities are Causing Me Problems</title>
</head>
<body>
<p>Copyright © 2010 Some Bloke</p>
</body>
</html>
EOF;
$imp = new DOMImplementation ();
$html5 = $imp->createDocumentType ('html', '', '');
$doc = $imp->createDocument ('http://www.w3.org/1999/xhtml', 'html', $html5);
$doc->loadXML ($text);
header ('Content-Type: application/xhtml+xml; charset: utf-8');
echo $doc->saveXML ();
Run Code Online (Sandbox Code Playgroud)
结果是:
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Entity 'copy' not defined in Entity, line: 8 in testing.php on line 19
如何在允许自己将页面作为XHTML5提供的同时解决这个问题?
我需要一种方法来替换HTML ASCII代码,就像!在bash中使用正确的字符一样.
有没有一个实用程序,我可以运行我的输出来做这个,或沿着这些线?
为什么margin:2.5px不起作用?在我的代码中的一种情况,我想margin:2.5px在IE6条件CSS中给出解决IE双边距和我的默认css margin:5px但在IE6 css中margin:2.5px并margin:2px创建相同的边距.然后如何margin在两个浏览器上相同?
这是默认屏幕CSS的代码
#newsHeadline LI
{font-weight: bold;
list-style-position: inside;
font-size: 13px;
margin: 5px 0px;
width: 320px;
line-height:
normal; list-style-type: disc;
position: relative}
Run Code Online (Sandbox Code Playgroud)
这是有条件的css代码我在写#newsHeadline LI {margin: 2.5px 0px}
编辑:15日
如果保证金:2.5px不起作用,那么如何在浏览器IE和FF中获得相同的保证金?还有其他方法吗?
c++ ×2
iphone ×2
ascii ×1
bash ×1
boost ×1
css ×1
domdocument ×1
entities ×1
gem ×1
html5 ×1
inheritance ×1
java ×1
objective-c ×1
performance ×1
php ×1
python ×1
ruby ×1
scala ×1
tdd ×1
templates ×1
while-loop ×1
xhtml ×1
xml ×1