473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Compile-time check for virtual function existence in derived class

Hi,

Actually I am creating a hierarchy of MANAGED classes.
I like to know if there is way to mark a virtual (abstract) function as
"must be implemented on each derived class".

example:

ref class Test abstract
{
public:
void read() abstract;
};

ref class TestDerived : Test
{
public:
void read() {}
};

ref class TestDerived2 : TestDerived
{
};

int main()
{
TestDerived2^ TD = gcnew TestDerived2();

return 0;
}

I'd like a compile-error for this code considering that 'void read()' is
not implemented for 'TestDerived2' class

Thanks fon any help.
Marco.

--
For direct reply change underscore to dot

Nov 17 '05 #1
3 1281
Hi Marco,
Actually I am creating a hierarchy of MANAGED classes.
I like to know if there is way to mark a virtual (abstract) function as
"must be implemented on each derived class". I'd like a compile-error for this code considering that 'void read()' is
not implemented for 'TestDerived2' class


Highly unlikely I'd guess, since TestDerived is a concrete class, and thus,
what you put in is valid code (since TestDerived2 actually *does* have the
read() implementation inherited from TestDerived)

What is it that you're trying to accomplish?
--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
Tomas Restrepo (MVP) wrote:

Highly unlikely I'd guess, since TestDerived is a concrete class, and thus,
what you put in is valid code (since TestDerived2 actually *does* have the
read() implementation inherited from TestDerived)
This is the same behaviour of a standard c++ class hierarchy (not managed).
What is it that you're trying to accomplish?


I like to know if in a hierarchy of managed classes
I am able to give to a virtual/abstract member-function of the class A
an attribute or other so that I may find out (at compiler-time)
if every derived class of A implements *its own* version of this
virtual/abstract member-function.

Marco.

--
For direct reply change underscore to dot

Nov 17 '05 #3
No, there is not, abstract like pure in standard C++ only works on the next
level of the inheritance hierarchy.

Ronald Laeremans
Visual C++

"Marco Segurini" <ma************@jumpy.it> wrote in message
news:uz**************@TK2MSFTNGP14.phx.gbl...
Tomas Restrepo (MVP) wrote:

Highly unlikely I'd guess, since TestDerived is a concrete class, and
thus,
what you put in is valid code (since TestDerived2 actually *does* have
the
read() implementation inherited from TestDerived)

This is the same behaviour of a standard c++ class hierarchy (not
managed).
What is it that you're trying to accomplish?


I like to know if in a hierarchy of managed classes
I am able to give to a virtual/abstract member-function of the class A an
attribute or other so that I may find out (at compiler-time)
if every derived class of A implements *its own* version of this
virtual/abstract member-function.

Marco.

--
For direct reply change underscore to dot

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mario T. Lanza | last post by:
I am working with Visual Studio. The solution I am developing is composed of about 8 separate projects. Some of these projects represent different tiers in the N-tiered architecture (data,...
0
by: Jordan Willms | last post by:
My xsl stylesheet is as simple as follows: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:ims="http://www.imsglobal.org/xsd/imsmd_v1p2"...
12
by: jrefactors | last post by:
If the C programs have UNIX system calls such as fork(), alarm(), etc.., we should call it UNIX programs, not traditional C programs? We couldn't compile the programs with system calls using VC++...
7
by: Arne | last post by:
I am porting a website to ASP.net 2.0. Temporarily I compile with Visual Studio 2003 and deploying to ASP.net 2.0. How do I compile my website under ASP.Net 2.0? I know it can compile each page as...
6
by: Tom | last post by:
I am developing my pages on my development machine and then copying to the production server. I am not pre-compiling, I am using the 'dynamic compile' feature. This is working fine except that...
5
by: DFB | last post by:
I am the author of the ZLibNetWrapper project on SourceForge (located at zlibnetwrapper.sf.net). This project is a simple mixed-mode .NET wrapper around the ZLib compression library. The ZLib...
1
by: brianrpsgt1 | last post by:
Newbie here.... I have been able to successful pull info from a MySQL DB, get the results and output them in an HTML format using Cheetah to the screen using IDLE. I am doing this on a Windows...
3
by: NvrBst | last post by:
Right now I have C99 code in .c extensions. I compile it in VSC++ and it complains about a lot of errors. I change the extensions to .cpp and compile in VSC++ and it succeeds. Is there a way...
4
by: Salad | last post by:
I have a database called MyApp.MDB. When I go into a module and want to compile the thing, it might have, on the menu bar line "Compile MyAppTest". IOW, the app name it's about to compile does...
6
by: Ed Leafe | last post by:
I've noticed an odd behavior with compile() and code that does not contain a trailing newline: if the last line is a comment inside of any block, a syntax error is thrown, but if the last line is a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.