Click here to Skip to main content
15,921,203 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Managed/Unmanaged: pinning ptr madness Pin
Jeff J28-Feb-03 22:25
Jeff J28-Feb-03 22:25 
GeneralImplementing IDisposable Pin
VizOne24-Feb-03 9:49
VizOne24-Feb-03 9:49 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 0:23
Paul Selormey25-Feb-03 0:23 
GeneralRe: Implementing IDisposable Pin
VizOne25-Feb-03 0:30
VizOne25-Feb-03 0:30 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 0:49
Paul Selormey25-Feb-03 0:49 
GeneralRe: Implementing IDisposable Pin
VizOne25-Feb-03 0:58
VizOne25-Feb-03 0:58 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 1:48
Paul Selormey25-Feb-03 1:48 
GeneralRe: Implementing IDisposable Pin
VizOne25-Feb-03 2:45
VizOne25-Feb-03 2:45 
Paul Selormey wrote:
Also, you trying to convert the IDisposable::Dispose() to virtual, it will compile but will not act as virtual method

Well I am sure it *does* act as a virtual method. Excerpt from MSDN doc on managed c++:

"The following features are supported for __gc interfaces:

All methods of an interface are implicitly pure virtual. Neither the keyword virtual nor the suffix =0 is required on an interface method declaration, although both are allowed"


Here is a small test in which I have included everything I mentioned so far. It works perfectly for me:

<br />
public __gc class B : public IDisposable<br />
{<br />
public:<br />
    virtual ~B() <br />
    { <br />
        Console::WriteLine("B::~B()");<br />
        InternalDispose(false); <br />
    }<br />
<br />
    virtual  void Dispose() <br />
    { <br />
        Console::WriteLine("B::Dispose()");<br />
        InternalDispose(true); <br />
    }<br />
<br />
protected:<br />
    // renaming this function to InternalDispose solved my problem<br />
    virtual void InternalDispose(bool arg)<br />
    {<br />
        Console::WriteLine("B::InternalDispose(bool)");<br />
        /* Clean up */ <br />
    }<br />
};<br />
<br />
public __gc class D : public B<br />
{<br />
public:<br />
    // just to show that the function *is* virtual<br />
    void Dispose() <br />
    { <br />
        Console::WriteLine("D::Dispose()"); <br />
        B::Dispose();<br />
    }<br />
protected:<br />
<br />
    void InternalDispose(bool arg)<br />
    {<br />
        Console::WriteLine("D::InternalDispose(bool)");<br />
        /* Clean up */<br />
        // call base classes implementation<br />
        B::InternalDispose(arg);<br />
    }<br />
};<br />
<br />
int _tmain(void)<br />
{<br />
  B * b = new D();<br />
  b->Dispose(); // as virtual as can be *g*<br />
}<br />


The output is (as expected)
D::Dispose()
B::Dispose()
D::InternalDispose(bool)
B::InternalDispose(bool)

Of course, in my final version I will mark B::Dispose() as __sealed and throw away D::Dispose()

- Andre
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 2:54
Paul Selormey25-Feb-03 2:54 
QuestionManaged type??? Pin
Orkun GEDiK21-Feb-03 12:49
Orkun GEDiK21-Feb-03 12:49 
AnswerRe: Managed type??? Pin
Paul Selormey23-Feb-03 1:46
Paul Selormey23-Feb-03 1:46 
GeneralRe: Managed type??? Pin
Orkun GEDiK23-Feb-03 3:55
Orkun GEDiK23-Feb-03 3:55 
GeneralRe: Managed type??? Pin
Paul Selormey23-Feb-03 23:49
Paul Selormey23-Feb-03 23:49 
GeneralRe: Managed type??? Pin
Orkun GEDiK24-Feb-03 10:48
Orkun GEDiK24-Feb-03 10:48 
GeneralRe: Managed type??? Pin
Paul Selormey25-Feb-03 0:30
Paul Selormey25-Feb-03 0:30 
GeneralRe: Managed type??? Pin
Orkun GEDiK25-Feb-03 10:59
Orkun GEDiK25-Feb-03 10:59 
GeneralAppDomain question... Pin
Orkun GEDiK21-Feb-03 11:28
Orkun GEDiK21-Feb-03 11:28 
GeneralProblems working witk wav data files Pin
matlab21-Feb-03 4:03
matlab21-Feb-03 4:03 
GeneralUnverifiable assembly 'GIS.View' failed policy check Pin
Paul Selormey16-Feb-03 22:42
Paul Selormey16-Feb-03 22:42 
GeneralRe: Unverifiable assembly 'GIS.View' failed policy check Pin
ThatsJustMe17-Feb-03 22:22
ThatsJustMe17-Feb-03 22:22 
GeneralRe: Unverifiable assembly 'GIS.View' failed policy check Pin
Paul Selormey20-Feb-03 2:20
Paul Selormey20-Feb-03 2:20 
GeneralNeed help with casting __gc-pointer to void* and then back again Pin
Anonymous16-Feb-03 12:52
Anonymous16-Feb-03 12:52 
GeneralRe: Need help with casting __gc-pointer to void* and then back again Pin
Paul Selormey16-Feb-03 19:26
Paul Selormey16-Feb-03 19:26 
GeneralRe: Need help with casting __gc-pointer to void* and then back again Pin
ThatsJustMe17-Feb-03 3:20
ThatsJustMe17-Feb-03 3:20 
GeneralRe: Need help with casting __gc-pointer to void* and then back again Pin
Paul Selormey17-Feb-03 13:13
Paul Selormey17-Feb-03 13:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.