CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 16

Threaded View

  1. #5
    Join Date
    Jun 2008
    Posts
    592

    Re: Array of objects

    Code:
    char n[29];
    Why not use std::string?
    Quote Originally Posted by Aashi
    yep sure it would be like this:
    I think you quoted more than what you intended because you didn't fix the unsafe practice of calling delete by hand which can be fixed with raii design at the least, but that is ok.
    Code:
    Stock *s1=new Stock[2];
    should be
    Code:
    unique_ptr< Stock [] >s1( new Stock[2] );
    which can also be
    Code:
    vector< Stock >s1( 2 );
    or even just
    Code:
    Stock s1[2];
    Last edited by Joeman; November 8th, 2011 at 03:28 AM.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured