![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 155
Rep Power: 3
![]() |
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 |
|
|
|
|
|
#2 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#3 | |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 155
Rep Power: 3
![]() |
Quote:
but yeah that may depend on how you interpret "method" |
|
|
|
|
|
|
#4 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
I would interpret method to be like an algorithm for handling allocation and deallocation.
|
|
|
|
|
|
#5 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>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. |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#7 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>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. |
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
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. |
|
|
|
|
|
#9 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
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. |
|
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4
![]() |
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! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|