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

Replace operator new question

Hello
Today, one of my friends said,"If you write a global operator new, you
will get a link error which complains new already defined in
msvcrt" (we are using MS VC++ 2005). I just said no, because C++
allows replacing global operator new. I have written a test, on static
lib with a global operator new, and an exe, and then all new linked to
my operator new. But he ask me, your operator new and the one defined
in msvcrt is just same function, how linker knows which to link? I can
not answer, anybody can tell me? Thanks a lot!
Nov 15 '07 #1
2 3346
Ne**********@gmail.com wrote:
Hello
Today, one of my friends said,"If you write a global operator new, you
will get a link error which complains new already defined in
msvcrt" (we are using MS VC++ 2005). I just said no, because C++
allows replacing global operator new. I have written a test, on static
lib with a global operator new, and an exe, and then all new linked to
my operator new. But he ask me, your operator new and the one defined
in msvcrt is just same function, how linker knows which to link? I can
not answer, anybody can tell me? Thanks a lot!
Most linkers will stop looking for a symbol once they found it. If you
make your function readily available, the linker will usually not use
the one that comes from the library listed later among the ones from
which to resolve symbols. More information is probably available in
a Microsoft Visual C++ newsgroup.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 15 '07 #2
Thanks for your reply.
I am looking for some articles on how linker works, would you like
give some links?
On Nov 15, 10:35 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
NeilFang2...@gmail.com wrote:
Hello
Today, one of my friends said,"If you write a global operator new, you
will get a link error which complains new already defined in
msvcrt" (we are using MS VC++ 2005). I just said no, because C++
allows replacing global operator new. I have written a test, on static
lib with a global operator new, and an exe, and then all new linked to
my operator new. But he ask me, your operator new and the one defined
in msvcrt is just same function, how linker knows which to link? I can
not answer, anybody can tell me? Thanks a lot!

Most linkers will stop looking for a symbol once they found it. If you
make your function readily available, the linker will usually not use
the one that comes from the library listed later among the ones from
which to resolve symbols. More information is probably available in
a Microsoft Visual C++ newsgroup.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 16 '07 #3

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

Similar topics

2
by: foo | last post by:
I'm creating a debug class called debug_mem_allocation for the purpose of finding memory leaks. I used macro's to replace the new and delete operators. My problem is with trying to replace the...
30
by: | last post by:
I have not posted to comp.lang.c++ (or comp.lang.c++.moderated) before. In general when I have a C++ question I look for answers in "The C++ Programming Language, Third Edition" by Stroustrup....
13
by: M | last post by:
Hi, I've searched through the previous posts and there seems to be a few examples of search and replacing all occurrances of a string with another string. I would have thought that the code...
5
by: Mahesha | last post by:
Hello, I need help in replacing one string pattern with another. Ex: I have a financial security expression like log(T 3.25 6/24/2004)/sqrt(T 4.5 6/19/2002) Here "T 3.25 6/24/2004" is a...
5
by: shaun roe | last post by:
I am about to replace a plain function which returns a string with an object; I am trying to preserve the interface to clients of the function, while imbuing the function with some internal state....
21
by: gary | last post by:
How would one make the ECMA-262 String.replace method work with a string literal? For example, if my string was "HELLO" how would I make it work in this instance. Please note my square...
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
14
by: inpuarg | last post by:
I want to find a & character using Regex. But not && How can i manage this in c# Quickfind window ? -------------------------------------------------- ne kadar yaarsan yaa sevdiin kadardr...
16
by: spl | last post by:
To increase the performance, how to change the / operator with bitwise operators? for ex: 25/5, 225/25 or 25/3 or any division, but I am not bothered of any remainder.
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.