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 phantomotap
    Yes. However, you have to avoid any use of polymorphism, not just the destructor.
    Well, you cannot really use inheritance based polymorphism anyway since the base class has no virtual member functions.
    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
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Well, you cannot really use inheritance based polymorphism anyway since the base class has no virtual member functions.
    I was going to give you the benefit of doubt. I've changed my mind. No explanation for you. That was stupid. You either jumped in with some random quip without bothering to understand what I was saying or you truly have no idea what you're talking about.

    Phantomotap also implies a solution, "You could export the member as a public interface", not sure where that fits in.
    It's just one of many possible ways to have the interface you want without inheriting `std::vector<???>'.

    Soma

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by laserlight View Post
    Well, you cannot really use inheritance based polymorphism anyway since the base class has no virtual member functions.
    Quote Originally Posted by phantomotap View Post
    I was going to give you the benefit of doubt. I've changed my mind. No explanation for you. That was stupid. You either jumped in with some random quip without bothering to understand what I was saying or you truly have no idea what you're talking about.
    Perhaps a third party view here would help.
    Phantomotap, in this instance I have to say that your comment above seemed out of line. I also misunderstood what you meant and could very well have posted a similar response to what laserlight did, making the same assumption. If you've been misunderstood, you only need to state that you have been misunderstood, and then explain your point in such a way as to clear up the misunderstanding.
    If my memory serves me well, you've provided valueable input in the past. So when you've put this behind you. I look forward to more valueable input from you. We all have our off days, just try and be a little more forgiving next time eh.

    On the other side of things, I too have inherrited from std::vector publicly a few times. Actually I've done it twice already in the project I'm working on! I'm using it purely as an alternative to declaring functions that take the vector as an argument, and am just declaring instances of this derived class within another class. No other members are added in the derived-from-vector class. For this I think it's quite appropriate.
    I believe I'm fully aware of what the effects of this are and I don't believe there are any noteworthy problems with this approach in this instance. In fact it has been used sucessfully in our production code in exactly this manner several times before.

    As always, there's an exception to every rule, and an exception quite likely doesn't apply to what the OP is doing.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

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