473,588 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I have one member function with two names? Like an Alias?

Tom
class CBlah
{
void MemberFun1( int x )
{ ... }
void MemberFun2( int x )
{ MemberFun1( x ); }
};

This doesn't look very efficient to me. Or might the compiler optimize MemberFun2 away? Or is there a better way to do this?

Thanks,
Tom.


Jul 19 '05 #1
1 2434
"Tom" <bl**@blah.co m> wrote in message news:<ME******* ************@ne ws01.bloor.is.n et.cable.rogers .com>...
class CBlah
{
void MemberFun1( int x )
{ ... }
void MemberFun2( int x )
{ MemberFun1( x ); }
};

This doesn't look very efficient to me. Or might the compiler optimize
MemberFun2 away? Or is there a better way to do this?


By writing the code within the class, you instruct the compiler to
"inline" the code for MemberFun1. Given its complexity, this is
likely to succeed. In debug mode, this often will be ignored though,
so you can fllow the code through MemberFun2

From an interface viewpoint, the second function doesn't add value
- although a real-world example might, with e.g. arguments
exchanged.

Regards,
--
Michiel Salters
Jul 19 '05 #2

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

Similar topics

0
3792
by: Fabster | last post by:
Below is a code part I got somewhere and works fine for retrieving a version from a single file. Now I want to retrieve all .dll, .ocx and ..exe file versions from my harddisk in all directory's. I generate a array of all those files and then in a loop request the version for each of those files. Now it randomly crashes with a error that it cannot write to memory at location xxxxxx. I cannot find the error and adding 'on error goto...
5
2955
by: stephan beal | last post by:
Good afternoon, C++ers, This weekend i came across a fairly project-neutral trick which can be used to map C++ class names to their human-readable equivalents (a-la QObject's className() method), without having to add methods to a client interface and without relying on (e.g.) typeid(T).name(). i understand that this may not be strictly a language-related post, but i think the solution is "template-enough" to be considered topical here.
5
3127
by: Walter Tross | last post by:
Somebody with a very regulatory mind in this newsgroup has written that it's better not to use a leading underscore for class member names, because names with a leading underscore are used internally by compilers (well, not so internally, since they appear in header files). I personally use the leading underscore (followed by a lower case letter), which I consider to be much more readable than the trailing underscore. My reasoning is...
2
3624
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't support. (first i compiled them with g++3.x. ERR means compiler will bark, otherwise it does accept it. Then the Comeau C/C++ 4.3.3 comes)
6
8562
by: Andre Eisenbach | last post by:
Should this code compile or not? class A { void f(); }; class B { friend void A::f();
20
2398
by: Ivar | last post by:
Hi, For my supprise I found that functions have 32 parameter limit. Where to find more info about this limitation or similar limitations ? I need at least 50, 100 would be ok. Real life function below:
6
4399
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
22
2049
by: Daniel Rucareanu | last post by:
I have the following script: function Test(){} Test.F = function(){} Test.F.FF = function(){} Test.F.FF.FFF = function(){} Test.F.FF.FFF.FFFF = function(){} //var alias = function(){}; var alias = Test.F.FF.FFF.FFFF;
4
1541
by: Sean McIlroy | last post by:
hi all is there a way to do this ... class clown: def __init__(self): self.x = 0 self.y = ALIAS(self.x) ## FEASIBLE ? .... so that you get results like this ...
0
8222
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...
1
7984
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
8223
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6634
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...
1
5726
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
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
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1458
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.