![]() |
|
#1
|
|||
|
|||
How can we trap errors in Constructors (C++)How can we trap errors in constructors as constructors will not retrun any values.
And one more question. What do you mean by the canonical form of a class Poolan |
|
#2
|
||||
|
||||
|
You could pass a reference parameter to the constructor and use that to notify you of an error. I'm assuming that you are doing File I/O or dynamic allocation, because normally, the constructor is used to do simple tasks like zeroing out all the variables in the class and such... anyhow, as for the canonical form of a class, I would start by looking up the word canonical.
__________________
-Aaron |
|
#3
|
||||
|
||||
|
This might be it...
Conforming to orthodox or well-established rules or patterns, as of procedure. This probably means using the class to represent a stack, queue, or linked list. Those are just examples of classes with well established rules and patterns. __________________
-Aaron |
|
#4
|
|||
|
|||
|
Quote:
1. You can throw exceptions. 2. Maybe this should be: "What does the instructor mean by the canonical form of a class?" The word "canonical" has been used in textbooks to mean a boilerplate beginning of all user-defined classes that corresponds to the most basic built-in classes: From http://cpptips.hyperformix.com/cpptips/orth_can_class Quote:
(You could have looked it up yourself, maybe?) Regards, Dave |
|
#5
|
||||
|
||||
|
I also think that throwing exceptions is DEFINETELY the way to go about this; if your compiler doesn't have a built in throw-catch or wathever mechanism, you could try the stl (in case it supports that) for its outstanding implementation
Another link regarding the canonical form: Hedlund. Kind regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#6
|
||||
|
||||
|
You guys are just too advanced for me. I would've suggested throwing exceptions, but I haven't learned how to do it yet.
__________________
-Aaron |
|
#7
|
|||
|
|||
|
Quote:
That's the reason I worded my #2 response the way I did. This is modestly called "Hedlund's Canonical Form" in class notes by an instructor named Hedlund. He does give a textbook reference. My advice to the original poster is to check his textbook or class notes for his instructor's take on "canonical" in this context. Regards, Dave |
Recent GIDBlog
Toyota - 2008 November Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help to debug complier errors | nkhambal | C Programming Language | 3 | 04-Oct-2004 09:26 |
| Wierd errors (again) | crystalattice | C++ Forum | 3 | 15-Aug-2004 21:02 |
| Subversive fun with a bot trap | jrobbio | MySQL / PHP Forum | 9 | 06-Jun-2004 00:54 |
| Error C2143: syntax error : missing ';' before 'type' | small_ticket | C Programming Language | 6 | 15-May-2004 12:59 |
| Can somebody look at this and point out any errors to me | soulfly | C Programming Language | 7 | 31-Mar-2004 10:45 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The