please validate: cannot have a delegate type nested inside sealed abstract ref class

  • Thread starter Ben Voigt [C++ MVP]
  • Start date
J

Jeffrey Tan[MSFT]

Hi Ben,

Yes, I can reproduce the error. However, in syntax level, the sealed
abstract class can only take static members, so why don't you define static
delegate like this:

public ref class C sealed abstract
{
delegate static void D(void);
};

I think this will go through the compiler check.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Ben Voigt [C++ MVP]

Jeffrey Tan said:
Hi Ben,

Yes, I can reproduce the error. However, in syntax level, the sealed
abstract class can only take static members, so why don't you define
static delegate like this:

A delegate isn't an instance member, it is a nested type. The static
modifier is not applicable to nested types, only to variables of that type.
public ref class C sealed abstract
{
delegate static void D(void);

For example, this works:

public:
ref class C2 { };

Only when declaring an instance of that type, is the keyword static needed:

static C2^ m_2;

static ref class C3
{
} ^m_3;
 
J

Jeffrey Tan[MSFT]

Hi Ben,

Sorry for the late response, I am out of office last friday.

Oh, yes, this sounds reasonable(Thank you for pointing out). Defining
delegate is defining a reference type, since we did not define an instance
of this type, no "static" is needed. It is strange the C++/CLI compiler
needs "static" keyword to compile through. Anyway, let's wait for the
official response from the VC++ team in that link.

Also, after you got it resolved, can you post here for sharing with the
community? Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top