Thread: losing pointers with destructor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by MK27
    Alright!
    That said, I am not entirely sure if overloading operator[] is the right thing to do. It kind of makes sense to me, i.e., a directory entry is a file (or information about a file), but then using a named member function might be clearer.

    Oh, and if you do overload operator[], you should const overload too: provide a version that works when the directory object is const.

    Finally, you might want to take a look at Boost.Filesystem.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by laserlight View Post
    That said, I am not entirely sure if overloading operator[] is the right thing to do. It kind of makes sense to me, i.e., a directory entry is a file (or information about a file), but then using a named member function might be clearer.

    if you do overload operator[], you should const overload too: provide a version that works when the directory object is const
    Unlikely that anyone but me will be using this -- but more generally, I don't mind having to pay attention and read docs and consider that "for the best". Thus: I don't feel a big need to bend over too far backward on the premise that the user won't bother.

    Also thinking the directory should always be const, is there a way to do that? (I guess keeping the vector private will have the same effect).

    Finally, you might want to take a look at Boost.Filesystem.
    Yeah, I noticed that. I am working on my own alternative, the "Hooch C++ libraries"... For some reason every time I approach a new language the first thing I want to do is tree the filesystem. Must be an i/o fetish.
    Last edited by MK27; 02-28-2010 at 10:04 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Frankly, other than the [...] ignore you in the future?
    I'm trying to help a newbie and you jump up to say "that was meaningless" without bothering to understand what I said? You get moody because I called you on your comment? You expect me to give more consideration to you than you give to me? You jump down on me and call me hostile?

    LMAO

    Who the hell do you think you are? Is this a joke? HAVEN'T WE HAD THIS CONVERSATION BEFORE?!

    You say you're going to ignore me? Considering that this is exemplar of our conversations would I notice the difference? Or would there just be less of you acting the part of put upon innocent because I don't offer you the preferential treatment you wrongly feel you deserve? I could get behind that. I'm certainly not going to give you a pass when screw up just because it might "really [make] [you] angry".

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers to arrays
    By rakeshkool27 in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 07:28 AM
  2. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  3. Variable pointers and function pointers
    By Luciferek in forum C++ Programming
    Replies: 11
    Last Post: 08-02-2008, 02:04 AM
  4. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM