Thread: This guy is thinking about quitting programming for good --------------------->

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    This guy is thinking about quitting programming for good --------------------->

    Ok I've been analyzing the same code for like one week now and I am starting to think that I am not made this stuff or maybe the book is just bad..............................
    PS this is not the whole code.

    String::String()
    {
    itsString = new char[1];
    itsString[0] = '\0';
    itsLen=0;
    }

    Ok, can you tell me that this does?
    Last edited by incognito; 01-21-2002 at 06:14 PM.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Waiting........I've already slapped myself about 5 times out of frustration!!!!!!!!!!!!!!!1
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  3. #3
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    This is an "implementation" statement...
    prior to this there was a "string" class declared.

    This a implementation of a "user-defined" constructor.
    ------- I hope that you know "classes"...???

    Every time you declare an object of the "string" class this constructor is called, and whatever is in the body of this constructor gets executed...

    which is...::::

    {
    itsString = new char[1]; // means that a compilers reserved an array of 2 characters of the "free store" (or heap); and assigned that empty space to the member variable "itsString"

    .... ---- Hope you know Pointers and little bit about "dynamic memory allocation".....???


    next...

    itsString[0] = "\0"; // this means....assign "NULL" to the first member of an array, in this case "itsString" with a substring [0]...

    ----- this array contains two (2) members declaration array[1]... is array[0] and array[1];

    the last one....

    itsLen = 0; // in this case ...assigns 0 to (most likely) private data member "itsLen", which "itsLen" is probably an integer....

    that's all it is....

    i am sure there's a lot more in that whole program but this should answer your questioon....as long as i didn't confuse you any more.

    good luck

    Regards,
    matheo917

  4. #4
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Ok, thanks a lot man, I really appreciate it.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  5. #5
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279

    good luck

    anytime....

    Regards,
    matheo917

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    new char[1] only allocated 1 byte of memory

  7. #7
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    1st of all: new char[1] creates space for one char on the free store and it is char[0]


    2nd of all: the book u r working out of is bad. i know because i was using it as well before i switched. try finding another book to work out of.

  8. #8
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Whose book?
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  9. #9
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Sam's Teach Yourself C++ in 21 Days

  10. #10
    Registered User
    Join Date
    Jan 2002
    Posts
    10
    Originally posted by golfinguy4
    Sam's Teach Yourself C++ in 21 Days

    i used that, it wasnt all that bad

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. small -> big -> bigger -> bigger than bigger -> ?
    By happyclown in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-11-2009, 12:12 PM
  2. Fluid Thinking
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 11-20-2002, 03:29 PM
  3. a british question/joke
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 06-02-2002, 01:05 PM