Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Mar 6th, 2007, 7:17 AM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Why are you putting "Functions" in a header file, instead of a source file? Presumably, these would be commonly used utility functions. In any but a trival, one-source-file program, such an approach would cause multiple definitions. These should be defined in a source file and declared in a header file.

You refer to it in a comment as a "class", but you show no class definition. A namespace is not a class, despite similarities. You may define classes in a header file because they are a pattern to be instantiated elsewhere.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 6th, 2007, 9:30 AM   #12
v0id
Hobbyist Programmer
 
Join Date: Apr 2006
Posts: 155
Rep Power: 3 v0id is on a distinguished road
@grumpy:
It's my first experience with bigger projects, and I think I've started badly with this project, right from the start. That's why I'll start from the scratch again, and then try to make it better. All your suggestions, haven't been waste of time, I've listened to them, and tried what I could to follow them. I just haven't could find much related to these things, in my code. About badalloc, then I actually forgot to check it within the try...catch. :o

@DaWei:
About the first thing, yes you're right, my bad.
The other thing; I wrote wrong, it should be "function", not "class".


Anyway, thanks for the help, both of you. I seems like I have to read alot more about pointers, before I'm going into bigger projects.
__________________
-- v0id
v0id is offline   Reply With Quote
Old Mar 6th, 2007, 9:37 AM   #13
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by v0id View Post
About badalloc, then I actually forgot to check it within the try...catch. :o
Unfortunately, that doesn't explain your problem. If operator new failed, it would throw an exception and the program would exit unless the exception was caught. It would not cause a problem AFTER main() has returned, and not with operator delete.
grumpy is offline   Reply With Quote
Old Mar 6th, 2007, 9:50 AM   #14
v0id
Hobbyist Programmer
 
Join Date: Apr 2006
Posts: 155
Rep Power: 3 v0id is on a distinguished road
Quote:
Originally Posted by grumpy View Post
Unfortunately, that doesn't explain your problem. If operator new failed, it would throw an exception and the program would exit unless the exception was caught. It would not cause a problem AFTER main() has returned, and not with operator delete.
I'm not so good at english, so maybe I've understood something wrong.
What I meant, was that I actually forgot to catch bad_alloc. I was only catching some objects I'd made by myself, and no other, not even catch(...);
I just looked at you little article about exceptionhandling (DaWei's signature), and I'm gonna read that, so I can better at exceptionhandling too.
__________________
-- v0id
v0id is offline   Reply With Quote
Old Mar 7th, 2007, 2:39 AM   #15
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by v0id View Post
What I meant, was that I actually forgot to catch bad_alloc. I was only catching some objects I'd made by myself, and no other, not even catch(...);
That was my interpretation of what you meant.
grumpy 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Heap vs. Stack memory Eric the Red C++ 11 Oct 24th, 2006 6:18 PM
Objective C Memory Management problems Soulstorm Other Programming Languages 12 Jun 28th, 2006 7:54 AM
When to use the new keyword in C++? titaniumdecoy C++ 28 Mar 16th, 2006 12:36 PM
Problems with atoi(), getting memory value instead of int omdown C++ 5 Nov 1st, 2005 11:41 PM
Pointers in C (Part I) Stack Overflow C 4 Apr 28th, 2005 7:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:01 AM.

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