Thread: problem in manipulating a maped array

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    A map is much much much much much much much different than an array.

  2. #17
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    Quote Originally Posted by Masterx View Post
    tanx i didnt know that , all i was thinking was that, initially the" it "would point to the first element of the array , knowing that the array starts at 0 !
    consider the following:

    Code:
    int *i = new int[1];
    int *i0 = i;
    delete[]i;
    i = new int[2];
    does i0 necessarily still point to the first element of i?

  3. #18
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    FWIW you should be including the string header:
    Code:
    #include <string>
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #19
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    Quote Originally Posted by tabstop View Post
    A map is much much much much much much much different than an array.
    many tanx , thats definitely because of my lack of knowledge in map( i dont know anything about map , i just needed sth , and it come up to be map! i'll cover the stuff later.
    Quote Originally Posted by m37h0d View Post
    consider the following:

    Code:
    int *i = new int[1];
    int *i0 = i;
    delete[]i;
    i = new int[2];
    does i0 necessarily still point to the first element of i?
    tanx , really tanx , i now understand it , tanx a million for this great example
    Quote Originally Posted by hk_mp5kpdw View Post
    FWIW you should be including the string header:
    Code:
    #include <string>
    thanks , forgot to include that, but why does it still compile ? do we have such a thing implemented in iostream header file too?
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Masterx
    thanks , forgot to include that, but why does it still compile ? do we have such a thing implemented in iostream header file too?
    <iostream> might directly or indirectly #include <string>, but you should not rely on that.
    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

  6. #21
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    Quote Originally Posted by laserlight View Post
    <iostream> might directly or indirectly #include <string>, but you should not rely on that.
    tanx . ill remember that .
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Dynamically Increasing Array of Integers
    By laserlight in forum C++ Programming
    Replies: 30
    Last Post: 07-04-2008, 07:27 AM
  2. Array problem
    By TomBoyRacer in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2007, 11:35 AM
  3. Replies: 6
    Last Post: 02-15-2005, 11:20 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM