problem in manipulating a maped array

This is a discussion on problem in manipulating a maped array within the C++ Programming forums, part of the General Programming Boards category; A map is much much much much much much much different than an array....

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

  2. #17
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    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,801
    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
    493
    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
    21,773
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    493
    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


Page 2 of 2 FirstFirst 12
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, 10: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, 11:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21