![]() |
|
#1
|
|||
|
|||
Message ClassQuote:
k not sure what do do on the toString one but so far this is what i have: Message.h CPP / C++ / C Code:
Message.cpp CPP / C++ / C Code:
and i havent writen the driver yet. but neet help with the toString Oh and what is a destructor? Last edited by LuciWiz : 30-Nov-2006 at 05:27.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#2
|
|||
|
|||
Re: Message Classanyone? ???
|
|
#3
|
|||
|
|||
Re: Message ClassFor toString, you need to figure out what a string representation of a Message object is. It could be something like this
Quote:
A destructor is a function called as your class is going out of existence (at the end of the scope* in which it was declared, or for dynamically allocated objects, when delete is called). The destructor should clean up any remaining loose ends in the class. If the class holds pointers to any dynamically allocated memory (like a C-style char* allocated with new[]) then it should release the memory to prevent memory leaks. Likewise, if the class holds a handle to a resource (like a file or an internet connection or whatever) it should close the handle for the same reason. The destructor takes no parameters and returns nothing. It is declared like this: CPP / C++ / C Code:
*The scope is basically anything between { and }. Variables inside a scope are destroyed when the scope ends, and are not visible from outside it. So a function has its own scope, but so does an if statement within the function, loops, etc. Google can provide you with a more detailed explanation. **Here's the complex explanation. The problem is that if an exception is thrown from anywhere, the stack begins to unroll. This is basically walking backwards in time, back through any function calls. As this happens, scopes are exited and any classes declared within those scopes are destructed. Now, what happens if you throw an exception while an exception is propagating? Well, the designers of C++ couldn't find an acceptable solution, so they decided the answer is CRASH. |
|
#4
|
|||
|
|||
Re: Message ClassSo destructors pass no paramaters? k... could i get an example of just a basic program driver for a destructor?
And the toString Message should be everything bundled up i belive? but the functions you spoke about i havent learned yet, so maybe i could make a c-string? |
|
#5
|
|||
|
|||
Re: Message ClassI havent finished this but im kind of stuck.. i need a little help still on the toString Function still. and the driver.
So far i have something like this: CPP / C++ / C Code:
I want the end result to look like: Quote:
|
|
#6
|
|||
|
|||
Re: Message ClassCurrent:
message.h CPP / C++ / C Code:
Message.cpp CPP / C++ / C Code:
New driver: CPP / C++ / C Code:
|
Recent GIDBlog
Last Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Box Class, need help again :( | TransformedBG | CPP / C++ Forum | 7 | 13-Nov-2006 15:11 |
| Card class help | verticalvoid | CPP / C++ Forum | 2 | 29-Jun-2006 21:51 |
| a tester class and then some. | postage | Java Forum | 1 | 06-May-2006 15:48 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | CPP / C++ Forum | 2 | 19-Dec-2004 06:06 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 03:38 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The