473,405 Members | 2,171 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,405 software developers and data experts.

an empty class?

84
I have a program that I'm trying to understand with the following code in a header file:
Expand|Select|Wrap|Line Numbers
  1. class  Mathobject {};
  2.  
  3. typedef void (Mathobject::*moDerivs) (const double, const double*, double*) const;  //! common derivs for Nrecipes ODE
  4. typedef double (Mathobject::*moSingle) (const double) const; //! Simple f(x)   
  5.  
  6.  
Hence it is adefinition of the class mathobject without any member function or objects declared. My interpretation is that one can add any function to this class (via the ::) as being a member function... is this right? Because it seems to be done just afterwards.
Mar 22 '07 #1
3 1247
Ganon11
3,652 Expert 2GB
Although I can't say it with any authority, that would appear to be correct...that is, I think your interpretation is correct, but I can't be sure.
Mar 22 '07 #2
sanctus
84
It is also motivated by the fact that the guy who wrote the program explains beforehand the reason of existence of this class as being (shortened by me):
Reason of existence: if an object (=belonging to a given class) calls a function f1 which is not of the given class and that function f1 needs another function f2 of the given class as well as data from the object, then the object and the function f1 need to belong to the same class. Hence mathobject defines a kind of mother class of all classes.

Thanks anyway, if we are already in two thinking it is right the probability being it tends more and more to one.
Mar 22 '07 #3
Banfa
9,065 Expert Mod 8TB
What you have is an empty class (that I suspect is being used as a base class for other classes) and type derfinitions of pointers to member functions.

Pointers to members (including member functions) are one of the more esoteric and less used features of C++.

Google Member Function Pointers

I liked this tutorial


Basically a member function pointer allows you to record a pointer to a particular function in a class and then use it on different objects of that class.

In this case it seems to be being used to enable visibility of functions and data between classes although I think there are other ways of doing that.
Mar 22 '07 #4

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

Similar topics

3
by: Emmanuel Thomé | last post by:
This is a comment aside the empty class behavior FAQ. I understand there are a fair number of reasons which make empty classes have non-zero size (except as base classes). If ``class foo'' were...
3
by: Markus Dehmann | last post by:
I have a two different value types with which I want to do similar things: store them in the same vector, stack, etc. Also, I want an << operator for each of them. class Value{}; // this would...
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
9
by: Søren M. Olesen | last post by:
Hi Can someone tell me how to implement something similar to String.Empty ?? Given a class called myValue Public class myValue private id as integer private value as string end class
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
4
by: avranju | last post by:
Hi, We have a few exception marker classes in a project that are used only to throw exceptions. I mean stuff like this (this may not be such a hot idea for doing exception handling - a simple...
8
by: meendar | last post by:
what will a object of an Empty class( contain nothing), do on default.What are all the default methods it calls. what is the use of creating the object for an empty class?
7
by: kumar.senthil | last post by:
Hi, I'm using XmlSerializer to create an object from the XML string. I would like to know whether I can get a null value for an empty XML element. Actually the XmlSerializer assigns "" (empty...
26
by: anonieko | last post by:
In the past I always used "" everywhere for empty string in my code without a problem. Now, do you think I should use String.Empty instead of "" (at all times) ? Let me know your thoughts.
9
by: Dhiru1009 | last post by:
Hi guys, I am trying to build a user registration form using PHP and MYSQL but encountring a problem. When I click on submit with empty fields it adds records to database also it doesn't matter...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.