Hi Everyone,
I have a function defined in a source file,
sample.cpp
int doit()
{
cout<<"in doit function"<<endl;
}
Now i need to make sure that this function is not overloaded by other
developers, is there anyway to ensure the same? 9 1707
Rahul wrote:
I have a function defined in a source file,
sample.cpp
int doit()
{
cout<<"in doit function"<<endl;
}
Now i need to make sure that this function is not overloaded by other
developers, is there anyway to ensure the same?
No, there's no way to ensure anything like that.
Although it is not immediately clear what you mean by "this function". Function
'doit(void)' cannot be "overloaded" from what you defined it to be. Function
'doit' with a different set of parameters can be.
--
Best regards,
Andrey Tarasevich
On Mar 24, 7:08 pm, Andrey Tarasevich <andreytarasev...@hotmail.com>
wrote:
Rahul wrote:
I have a function defined in a source file,
sample.cpp
int doit()
{
cout<<"in doit function"<<endl;
}
Now i need to make sure that this function is not overloaded by other
developers, is there anyway to ensure the same?
No, there's no way to ensure anything like that.
Although it is not immediately clear what you mean by "this function". Function
'doit(void)' cannot be "overloaded" from what you defined it to be. Function
'doit' with a different set of parameters can be.
--
Best regards,
Andrey Tarasevich
Yes, i meant, i don't want any other developer to have the same
function name with different set of arguements...
Rahul wrote:
Hi Everyone,
I have a function defined in a source file,
sample.cpp
int doit()
{
cout<<"in doit function"<<endl;
}
You have to see function overloading a bit like using identical function
names with different argument list. there is more to it, but this could
be the crude idea. So can somebody overload
int doit();
The answer is no
but he can overload
output doit(with_this);
Obviously a developer can always overload int doit() by directly
altering your code, or if you don't give him your code, he can just kick
it out of the library and incorporate his own.
Yes, i meant, i don't want any other developer to have the same
function name with different set of arguements...
Then I think you would need to create all those functions yourself with
bogus and incorporate them in a library.
Rahul wrote:
Yes, i meant, i don't want any other developer to have the same
function name with different set of arguements...
Why?
Brian
On Mar 24, 12:03*pm, "Default User" <defaultuse...@yahoo.comwrote:
Rahul wrote:
Yes, i meant, i don't want any other developer to have the same
function name with different set of arguements...
Why?
Brian
I think there is a symbol table option that errors on a collision. I
had a similar issue with 3rd party libraries and some global symbols.
To avoid this problem entirely, use namespaces, scope everything as
tiny as possible, and prepend names (if you're using pure C). E.g.,
MySection::doit() or MySection_doit().
On Mar 24, 5:38 pm, Rahul <sam_...@yahoo.co.inwrote:
Hi Everyone,
I have a function defined in a source file,
sample.cpp
int doit()
{
cout<<"in doit function"<<endl;
}
Now i need to make sure that this function is not overloaded by other
developers, is there anyway to ensure the same?
extern "C"
{
#include <sample.h>
}
I would have the prototype of my function in the header file. I would
expect other developers to put in their prototypes too in the header
file as and when they include their overloaded function's prototype in
the header file, g++ compiler would give a compilation error...
Rahul wrote:
On Mar 24, 5:38 pm, Rahul <sam_...@yahoo.co.inwrote:
>Hi Everyone,
I have a function defined in a source file,
sample.cpp
int doit() { cout<<"in doit function"<<endl;
}
Now i need to make sure that this function is not overloaded by other developers, is there anyway to ensure the same?
extern "C"
{
#include <sample.h>
}
I would have the prototype of my function in the header file. I would
expect other developers to put in their prototypes too in the header
file as and when they include their overloaded function's prototype in
the header file, g++ compiler would give a compilation error...
Put the (conditionally compiled for C++) extern "C" wrapper in the header.
--
Ian Collins.
Rahul wrote:
...
extern "C"
{
#include <sample.h>
}
I would have the prototype of my function in the header file. I would
expect other developers to put in their prototypes too in the header
file as and when they include their overloaded function's prototype in
the header file, g++ compiler would give a compilation error...
...
So, what you said above, is it a part of the original question or the answer to
the original question?
--
Best regards,
Andrey Tarasevich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Doran_Dermot |
last post by:
Hi All,
I've seen lots of code in which the attributes of a class are accessed and
modified using two separate methods. For example:
class Problems:
def __init__( self, refNum ):...
|
by: Dave Theese |
last post by:
Hello all,
I'm trying to get a grasp of the difference between specializing a function
template and overloading it. The example below has a primary template, a
specialization and an overload. ...
|
by: |
last post by:
I have a class with overloading operator new. (Because, if an identical object exists, return a pointer to existed object instead of
a new pointer)
It has no sense (it is dangerous) to allocate an...
|
by: WittyGuy |
last post by:
Hi,
What is the major difference between function overloading and function
templates?
Thanks!
http://www.gotw.ca/resources/clcm.htm for info about ]
|
by: zeus |
last post by:
I know function overloading is not supported in C.
I have a few questions about this:
1. Why? is it from technical reasons? if so, which?
2. why wasn't it introduced to the ANSI?
3. Is there any...
|
by: JaSeong Ju |
last post by:
I would like to overload a C function. Is there any easy way to do this?
|
by: asdf |
last post by:
They looks so similar. Anybody would like to tell me their differences?
Thanks a lot.
|
by: lordkain |
last post by:
is it possible to do some kind of function overloading in c? and that
the return type is different
|
by: Matthew |
last post by:
Am I correct in thinking there is no method/function overloading of any
kind in any version of PHP?
Thanks,
Matthew
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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,...
| |