473,802 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1297
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******** ******@TK2MSFTN GP14.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
4476
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, business logic, presentation, etc.). Right now, some of the projects are inter-related and reference each other using Project References. When I select "Rebuild Solution" to compile, each project is successfully compiled into its own directory (and...
0
2631
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" xmlns="http://ltsc.ieee.org/xsd/LOMv1p0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/> <!-- rename ims datetime tags to IEEE dateTime tags --> <xsl:template match="ims:datetime">
12
3458
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++ compiler. I need to compile it under UNIX platform. correct? any other alternatives?? Please advise. Thanks!!
7
1686
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 I touch it. During the beta there used to be something like mywebsite.com/compile.??? that you could run. Does it still exist?
6
2662
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 everytime I change a page on the production server I need to restart IIS to effect the change. If I don't restart IIS, it tries to recompile but gets and error ( 'cannot execute a program......vbc.exe......). Am I missing something which allows...
5
5381
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 code consists of a few C source files. For Visual Studio 2003, this wrapper compiled fine without having to change any of the ZLib source. However, according to "Breaking Changes in the Visual C++ 2005 Compiler" (at...
1
3083
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 Laptop, running WinXP, Python 2.5 and the latest version of Cheetah. I have two questions: 1. How and where do you compile Cheetah templates in Windows? The command in the docs is cheetah compile a, however, I believe that this
3
2313
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 to keep my extensions .c, but tell VSC++ (through an project option) to compile as C++98 code (as if it had .cpp extensions).
4
2320
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 not match the application name. This is a bit disconcerting but seems to not affect anything. Any reason why A2003 doesn't know the name of the app it's compiling. I never worried about something like this with A97 since it simply says "Compile...
6
1960
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 non- comment Python statement, there is no error. Here's an example (using 2.5.1 on OS X) .... def foo(): .... print 'bar' """ <code object <moduleat 0x79608, file "", line 2>
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10535
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10303
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10282
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.