抽象密封&文字 [英] abstract sealed & literal

查看:87
本文介绍了抽象密封&文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ref struct XXX abstract sealed

{

literal int A = 5;

};


上面的定义给了我编译器警告C4693:一个密封的摘要

类不能有任何实例成员''A''。相同的定义是

在其他CLR语言中完全合法。例如在C#中;


静态类XXX

{

const int A = 5;

}


编译没有任何错误。有没有办法在C ++ / CLI中的静态类中指定CLR兼容的参数


解决方案

你没有'在C#中得到相同的数量。

那将是:

公共抽象密封类XXX

{

}

-

David Anton
www.tangiblesoftwaresolutions.com

即时C#:VB到C#转换器

即时VB:C#到VB转换器

即时C ++ :C#/ VB到C ++转换器

即时Python:C#/ VB到Python转换器

" Vedo"写道:


ref struct XXX abstract sealed

{

literal int A = 5;

};


上面的定义给了我编译器警告C4693:一个密封的摘要

类不能有任何实例成员''A '' " ;.相同的定义是

在其他CLR语言中完全合法。例如在C#中;


静态类XXX

{

const int A = 5;

}


编译没有任何错误。有没有办法在C ++ / CLI中的静态类中指定CLR兼容的对象



并且出现错误消息进入C#是:抽象类不能被密封

或静态。

-

David Anton
< a rel =nofollowhref =http://www.tangiblesoftwaresolutions.comtarget =_ blank> www.tangiblesoftwaresolutions.com

即时C#:VB转换为C#转换器

即时VB:C#到VB转换器

即时C ++:C#/ VB到C ++转换器

即时Python:C#/ VB到Python转换器

" David Anton"写道:


你没有相应的C#。

那将是:

public抽象密封班XXX

{

}

-

David Anton
www.tangiblesoftwaresolutions.com

即时C#:VB转C#转换器

即时VB:C#到VB转换器

即时C ++:C#/ VB到C ++转换器

即时Python:C#/ VB到Python转换器


Vedo写道:


ref struct XXX abstract sealed

{

literal int A = 5;

};


上面的定义给了我编译器警告C4693:一个密封的摘要

类不能有任何实例成员''A '' " ;.相同的定义是

在其他CLR语言中完全合法。例如在C#中;


静态类XXX

{

const int A = 5;

}


编译没有任何错误。有没有办法在C ++ / CLI中的静态类中指定CLR兼容的参数







感谢您的回复。 Aref class XXX abstract sealed C ++ / CLI中的类

编译为.class abstract sealed XXX在MSIL中,这意味着静态

类XXX在C#中。因此在您的示例中,您在C#中使用相同的关键字,但

在语义上它们是不同的声明。


不知何故,C ++ / CLI编译器不允许我使用在一个

静态类中定义CLR常量,这通常在CLR中允许。


" Vedo" < ve ** @ vedo.com写信息

news:ug ************** @ TK2MSFTNGP02.phx.gbl ...
< blockquote class =post_quotes>
ref struct XXX abstract sealed

{

literal int A = 5;

};


上面的定义给了我编译器警告C4693:一个密封的

抽象类不能有任何实例成员''A''。等效的

定义在其他CLR语言中是完全合法的。例如在C#中;


静态类XXX

{

const int A = 5;

}


编译没有任何错误。有没有办法在C ++ / CLI中的静态类中指定CLR兼容

consts?



ref struct XXX abstract sealed
{
literal int A = 5;
};

The definition above gives me the compiler warning "C4693: a sealed abstract
class cannot have any instance members ''A''". The equivalent definition is
perfectly legal in other CLR languages. For example in C#;

static class XXX
{
const int A = 5;
}

compiles without any error. Is there a way to specify CLR compatible consts
in a static class in C++/CLI?

解决方案

You haven''t got the equivalent in C#.
That would be:
public abstract sealed class XXX
{
}
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Vedo" wrote:

ref struct XXX abstract sealed
{
literal int A = 5;
};

The definition above gives me the compiler warning "C4693: a sealed abstract
class cannot have any instance members ''A''". The equivalent definition is
perfectly legal in other CLR languages. For example in C#;

static class XXX
{
const int A = 5;
}

compiles without any error. Is there a way to specify CLR compatible consts
in a static class in C++/CLI?


And the error message you get in C# is: "an abstract class cannot be sealed
or static".
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"David Anton" wrote:

You haven''t got the equivalent in C#.
That would be:
public abstract sealed class XXX
{
}
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Vedo" wrote:

ref struct XXX abstract sealed
{
literal int A = 5;
};

The definition above gives me the compiler warning "C4693: a sealed abstract
class cannot have any instance members ''A''". The equivalent definition is
perfectly legal in other CLR languages. For example in C#;

static class XXX
{
const int A = 5;
}

compiles without any error. Is there a way to specify CLR compatible consts
in a static class in C++/CLI?


Hi,

Thank you for your reply. A "ref class XXX abstract sealed" class in C++/CLI
is compiled to ".class abstract sealed XXX" in MSIL which means "static
class XXX" in C#. So in your example you use the same keywords in C#, but
semantically they are different declarations.

Somehow the C++/CLI compiler does not allow me to define CLR constants in a
static class, which is normally allowed in CLR.

"Vedo" <ve**@vedo.comwrote in message
news:ug**************@TK2MSFTNGP02.phx.gbl...

ref struct XXX abstract sealed
{
literal int A = 5;
};

The definition above gives me the compiler warning "C4693: a sealed
abstract class cannot have any instance members ''A''". The equivalent
definition is perfectly legal in other CLR languages. For example in C#;

static class XXX
{
const int A = 5;
}

compiles without any error. Is there a way to specify CLR compatible
consts in a static class in C++/CLI?



这篇关于抽象密封&amp;文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆