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

[BEGINNER] new keyword

I was asked in an interview if using new can we assign memory at a
known address. If yes, does it mean new operator can be overloaded like
others?

Thanks for your response

Jul 23 '05 #1
6 2315
Last Timer wrote:
I was asked in an interview if using new can we assign memory at a
known address. If yes, does it mean new operator can be overloaded like
others?

Thanks for your response


Yes, yes. See the FAQ below.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 23 '05 #2
Last Timer wrote:
I was asked in an interview if using new can we assign memory at a
known address.
Yes.
If yes, does it mean new operator can be overloaded like others?


Yes.

Jul 23 '05 #3
Checked the FAQ. Can someone please give examples of how new can be
overloaded/assign memory at a known address.

Thanks

Jul 23 '05 #4

"Last Timer" <da********@yahoo.com> skrev i en meddelelse
news:11**********************@l41g2000cwc.googlegr oups.com...
Checked the FAQ. Can someone please give examples of how new can be
overloaded/assign memory at a known address.

Thanks


void* adress = ... ;
myclass *mc = new(adress) myclass(...);

/Peter
Jul 23 '05 #5
On Sat, 5 Mar 2005 23:46:09 +0100, "Peter Koch Larsen"
<pk*****@mailme.dk> wrote:

"Last Timer" <da********@yahoo.com> skrev i en meddelelse
news:11**********************@l41g2000cwc.googleg roups.com...
Checked the FAQ. Can someone please give examples of how new can be
overloaded/assign memory at a known address.

Thanks


void* adress = ... ;
myclass *mc = new(adress) myclass(...);

/Peter

This use of the new operator Peter shows is called "placement new" and
is covered in the C++ FAQ LITE in the section on destructors. If you
wish to use placement new, these portions of the FAQ are highly
recommended reading.

[11.10] What is "placement new" and why would I use it?
http://www.parashift.com/c++-faq-lit...html#faq-11.10

[11.14] Is there a way to force new to allocate memory from a specific
memory area?
http://www.parashift.com/c++-faq-lit...html#faq-11.14
--
Kanenas
Jul 23 '05 #6

"Kanenas" <kanenas_@t_comcast_d.t_net> wrote in message
news:jj********************************@4ax.com...

This use of the new operator Peter shows is called "placement new" and
is covered in the C++ FAQ LITE in the section on destructors.


Funny place to put info on object construction, in the section on
destructors... :-)
-H
Jul 23 '05 #7

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

Similar topics

3
by: Rodney Dunning | last post by:
Hello, I've just picked up python to create some 3D visuals (using VPython) for a physics class I'm developing. While writing a program, I developed a "bug" that is reflected in the code below....
13
by: Martin | last post by:
I have 5 days of experince with XSLT and I am sure my problem is pretty much as basic as they come but I cannot work it out, so I hope someone will take pity on me - please! I have inherited an...
15
by: Pelle Beckman | last post by:
Hi all, I have a few newbie questions: In function declaration what does a 'const' mean inside the parameter list ? That it won't modify the value? void MemberFunction(const int x);
8
by: Bshealey786 | last post by:
Okay im doing my final project for my first computer science class(its my major, so it will be my first of many), but anyway im a beginner so im not to great with C++ yet. Anyway this is the error...
10
by: Lloyd Dupont | last post by:
how do I redefine the new operator? for all the structure I use at once! (some of them comes from C include files). The rationale: I'm writting a managed C++ wrapper around C API (external...
0
by: Dave | last post by:
I created a C# ASP.Net project in Visual Studio 2003 called CS1. When I navigate to http://localhost/CS1/webform1.aspx, my new ASP.Net web page displays fine. But I want to rename the page to...
4
by: R.A.M. | last post by:
When to use "readonly" and when to use "const"? Could you explain me please? Thank you very much! /RAM/
2
by: R.A.M. | last post by:
Hello, I have started larning C# and I have a question concerning "using (...)" keyword. For example: using (SqlConnection connection = new SqlConnection(ConnectionString)) {...
0
by: odysseyphotography | last post by:
Hi, I'm trying to build a simple search for a database of jobs. Users can search using three groups of critera: 1) Area (check boxes) Buying and merchandising Design Executive
5
by: nescio | last post by:
hello, i am making a form using php/html/javascript a part of the form is (email address) comming from a database. the amount of addresses is always different. every address has a checkbox....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.