VS .NET Does Not Complain When Pure Virtual Method Isn't Defined 
Author Message
 VS .NET Does Not Complain When Pure Virtual Method Isn't Defined

I was implementing the IDisposable interface in several of my managed
classes using MC++.  In one case, I accidentally inherited from IDisposable
in a class that did not implement Dispose().  The compiler did not complain
(or even warn) when I compiled the DLL.  The DLL does create instances of
this particular (value) class, so I would have expected a compiler error, or
at least a linker error when the linker could not find the definition for
the Dispose method.  Here is what the class declaration looks like:

public __value class MyClass : public IDisposable //note: no Dispose method
declared/defined
  {
  public:
   Int32  Freq;
   MyFlag Flags;
   Byte  Collapse;
  };

I have a Windows Forms GUI written in C# that uses this class.  It, of
course, through a run-time exception when it couldn't find the definition
for the class' Dispose() method.

My only thoughts were that this was a value class and/or this class is
'inline' (i.e. no methods defined in a source file that are not inline).
Those are just thoughts though.  Any ideas why the compiler did not
complain?

Thanks,

Tim Rogers



Wed, 10 Aug 2005 02:37:26 GMT  
 VS .NET Does Not Complain When Pure Virtual Method Isn't Defined

| >Newsgroups: microsoft.public.dotnet.languages.vc
| >Subject: VS .NET Does Not Complain When Pure Virtual Method Isn't Defined
| >Date: Fri, 21 Feb 2003 13:37:26 -0500
| >
| >I was implementing the IDisposable interface in several of my managed
| >classes using MC++.  In one case, I accidentally inherited from
IDisposable
| >in a class that did not implement Dispose().  The compiler did not
complain
| >(or even warn) when I compiled the DLL.  The DLL does create instances of
| >this particular (value) class, so I would have expected a compiler
error, or
| >at least a linker error when the linker could not find the definition for
| >the Dispose method.  Here is what the class declaration looks like:
| >
| >public __value class MyClass : public IDisposable //note: no Dispose
method
| >declared/defined
| >  {
| >  public:
| >   Int32  Freq;
| >   MyFlag Flags;
| >   Byte  Collapse;
| >  };
| >
| >I have a Windows Forms GUI written in C# that uses this class.  It, of
| >course, through a run-time exception when it couldn't find the definition
| >for the class' Dispose() method.
| >
| >My only thoughts were that this was a value class and/or this class is
| >'inline' (i.e. no methods defined in a source file that are not inline).
| >Those are just thoughts though.  Any ideas why the compiler did not
| >complain?
| >
| >Thanks,
| >
| >Tim Rogers
| >
|

*** this is a bug in the compiler, and is fixed in the 7.1 compiler visual
studio 2003 due for release in april.
      sorry for the grief :-(

--
Stanley Lippman, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Wed, 10 Aug 2005 03:01:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating a Virtual directory through a program as done by VS.NET IDE

2. Error R6025 - Pure Virtual Method missing confusion

3. Compiler not complaining about multiply defined variable

4. beginer: What's pure virtual base class?

5. std::copy isn't doing what I expect

6. pure virtual function and virtual function

7. NULL isn't 0/0 isn't NULL

8. typeof isn't enough to define swap correctly

9. CPropertySheet OnOK-method isn't called, why?

10. VS.NET Enterprise Vs VS.NET Professional

11. Virtual methods not working in my ATL Control

12. Howto define ado2.7 seek method's multi-column search variant

 

 
Powered by phpBB® Forum Software