Thread: Unexplainable Segvault in Constructor Method

  1. #16
    Registered User
    Join Date
    Nov 2014
    Posts
    9
    Edited my post.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Looks correct. I suggest that you declare str to be a const char* for const-correctness.
    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

  3. #18
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Isn't the super const-correct form :
    Code:
    const char* const
    ?

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    That second const makes no difference to the caller and is effectively implementation detail.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I call a method without it's constructor first?
    By JazzEngineer in forum C# Programming
    Replies: 5
    Last Post: 09-07-2013, 01:28 AM
  2. Unexplainable behavior...
    By wpcarro in forum C Programming
    Replies: 6
    Last Post: 01-06-2011, 06:15 PM
  3. Using my own method in a constructor...
    By AngryStyro in forum C++ Programming
    Replies: 13
    Last Post: 06-04-2008, 01:02 PM
  4. Windows Service class constructor and OnStart method
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 04-14-2008, 07:18 AM
  5. yet another unexplainable flaw
    By stormbreaker in forum C++ Programming
    Replies: 4
    Last Post: 06-01-2003, 12:56 PM

Tags for this Thread