在GCC上编译时,我得到错误:函数定义上的纯指定符,但是当我使用VS2005编译相同的代码时却没有.
class Dummy {
//error: pure-specifier on function-definition, VS2005 compiles
virtual void Process() = 0 {};
};
Run Code Online (Sandbox Code Playgroud)
但是当这个纯虚函数的定义不是内联时,它的工作原理是:
class Dummy
{
virtual void Process() = 0;
};
void Dummy::Process()
{} //compiles on both GCC and VS2005
Run Code Online (Sandbox Code Playgroud)
错误意味着什么?为什么我不能内联?如第二个代码示例所示,避免编译问题是否合法?
以下代码无法编译,因为两个乘法运算符在擦除后具有相同的类型:(f: Object)Object
我知道类型擦除,但我见过的所有情况都擦除了泛型类型,如List[Int]或者List[String],在Scala双重定义中回答(2种方法具有相同类型的擦除).
如何让Scala对待不同类型的XxxT`类型不同?
trait AbstractTypes {
type ScalarT
type VectorT
abstract class Operators(u: VectorT) {
def *(f: ScalarT): VectorT
def *(v: VectorT): VectorT
}
}
Run Code Online (Sandbox Code Playgroud)