473,395 Members | 1,516 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,395 software developers and data experts.

virtual static property - how to make it work

Hello!

I know that there is no way of making a property both static and virtual, but is there a way around it? I have a situation where I have an abstract class, and a bunch of classes that derive that class. Now, each derived class has some properties that define them, and these properties must be only type dependent and not instance dependent. To make matters worse, I initialize the derived classes using reflection (the Activator class). What I would like to be able to do is to get these properties of each class using only the type of the derived class without initializing it! Is this in any way possible?

It would look something like this:

Expand|Select|Wrap|Line Numbers
  1. abstract public class Base
  2. {
  3.     virtual static public bool Property { get; }
  4. }
  5.  
  6. public class Derived : Base
  7. {
  8.     static public bool SomeProperty { get { return true; } }
  9. }
  10.  
So, writing "Derived.Property" should return "true".
May 12 '10 #1
0 1109

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: john smith | last post by:
I'm wondering if it's possible to declare a pure virtual member function? Ie is: class A{ public: virtual static void f() const = 0; }; legal? I'm getting compile errors for code that used...
2
by: Tony Johansson | last post by:
Hello Experts! I know that you can't have virtual static methods and I know what a static method is. A static method exist only one time no matter how many object you have. You have this...
3
by: Donald Gillies | last post by:
So I have a virtual base class. I want each child class to have its own unique log. There may be hundreds of child classes but all classes of a particular type should share one log. After...
2
by: Pavils Jurjans | last post by:
Hello, I wanted to get some feedback on why there are not allowed virtual static members in C#. Say, I have the Parent class, that hosts number of protected methods, that occasionaly make...
4
by: Ole Nielsby | last post by:
Here comes a generic class with a static property. Let's say they are exotic singleton pets. abstract class Pet {...} abstract class SharedPet<T>: Pet where T: SharedPet<T>, new() {...
7
by: sunil | last post by:
Hi, I am dealing with problem where I need virtual+static function: enum {A=0,B=1}; Factory.cpp: ------------------ Base * createInstance(int classType,char *name) { if(classType == A)
10
by: Franky | last post by:
I think I misread a post and understood that if I do: System.Windows.Forms.Cursor.Current = Cursors.WaitCursor there is no need to reset the cursor to Default. So I made all the reset...
5
by: Ralfeus | last post by:
Hi all. I have a base class and several classes inherited from this base class. I need to create a instances counter for each class. I thought about something like creation of virtual static...
10
by: =?Utf-8?B?Y2FybG0=?= | last post by:
Hello, I searched for an answer to my question and found similar posts, but none that quite addressed the issue I am trying to resolve. Essentially, it seems like I need something like a virtual...
4
emibt08
by: emibt08 | last post by:
Hi. I know the title looks a little bit silly and that we can not have pure virtual static functions. But i've been wondering what approach to take to make the abstraction. This is the case: I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.