Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 8th, 2006, 1:11 AM   #1
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 155
Rep Power: 3 programmingnoob is on a distinguished road
what could "method" possibly mean here?

Describe a method for dynamic or heal memory allocation/deallocation which a compiler can use for implementing the new and delete functions of c++.

I am confused about what the question is asking (what method they talking about?) I dont want a solution yet
programmingnoob is offline   Reply With Quote
Old Sep 8th, 2006, 1:26 AM   #2
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
This belongs in the C++ forum.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Sep 8th, 2006, 1:39 AM   #3
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 155
Rep Power: 3 programmingnoob is on a distinguished road
Quote:
Originally Posted by a thing
This belongs in the C++ forum.
umm not necessarily, because this question is not from a c++ class.
but yeah that may depend on how you interpret "method"
programmingnoob is offline   Reply With Quote
Old Sep 8th, 2006, 2:55 AM   #4
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3 Jimbo is on a distinguished road
I would interpret method to be like an algorithm for handling allocation and deallocation.
Jimbo is offline   Reply With Quote
Old Sep 9th, 2006, 3:13 PM   #5
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>what method they talking about?
I hate the term method for class functions. It's confusing when method could mean other things, like an algorithm, or a concept (which is what the question seems to be talking about). In fact, C++ terminology uses the term "member function" rather than method, and I encourage you to think that way as well to save yourself headaches.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Sep 9th, 2006, 3:36 PM   #6
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
That's odd, because in Germany we are taught that they are methods, I had assumed, to differentiate them from c functions. (Deutsch: Methoden) A class has attributes and methods... etc.
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Sep 9th, 2006, 3:46 PM   #7
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>That's odd, because in Germany we are taught that they are methods
My German is rather weak, so I can't see how "member function" could be translated improperly to "method". The C++ standard makes no mention of methods, but explicitly uses member functions, so the terminology is official. Most likely you were taught by someone who mistakenly used OO terminology instead of proper C++ terminology. The "correct" term in the OO paradigm is method. Of course, it's well established that C++ is not a strict OO language, and using OO terms where they don't apply would confuse the bejeezus out of everyone. This thread being a good example.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Sep 12th, 2006, 1:12 AM   #8
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
are they wanting you to make clever use of malloc and free and such???

(basically write new and delete)

...?

?
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 12th, 2006, 6:03 AM   #9
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
Quote:
Originally Posted by programmingnoob View Post
Describe a method for dynamic or heal memory allocation/deallocation which a compiler can use for implementing the new and delete functions of c++.

I am confused about what the question is asking (what method they talking about?) I dont want a solution yet
Now that this question has sent people down an excursion of OO-speak (in which "method" is roughly the equivalent of the term "member function" in the C++ standard) and associated mumbo-jumbo, I'll offer a different meaning of "method".

One of the definitions of "method" in the English dictionary (a book that associates words with their meaning in the English language) is "a way of doing something".

Which suggests that an alternate way of wording the question would be "If you were writing a C++ compiler, describe a technique that could be used to manage dynamic memory allocation so you could implement operators new and delete."

English is a wonderful language sometimes. Too bad few computer programmers actually understand it.
grumpy is offline   Reply With Quote
Old Sep 12th, 2006, 8:50 AM   #10
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
If im not mistaken, 'new' and 'delete' are operators which takes the size of the guest object and allocates that ammount of memory from heap and dellocates etc and returns its address...your CRT takes care of this stuff.

You can relate them directly to malloc and free. Typically they work with OS to map large ammounts of memory to your application space at startup and then gives you addresses from that space when you call malloc etc.

So when it says "a method for dynamic or heap memory allocation/deallocation which a compiler..." its probably asking you to advise an algorithm to do that. For example
int x[] = new int[500]; is similar to something like int x[] = (int[500]*)malloc(sizeof(int[500]));
There would probably be some checks for if malloc returned 0 or something...these are related to "good practices."

You could test out concepts simply by overloading these operators...they go like new:
void * __attribute__((cdecl))__ new ( size_t size) ... you get the point
__________________
Spread your wings and fly! Chicken!
rsnd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC