slice_array problem in vs2005

Discussion in 'C++' started by holmescn, Mar 20, 2007.

  1. holmescn

    holmescn Guest

    Hi-
    Anyone here used vs2005?So I appreciate your help.
    I used stlport 5.0. When I complied the code below,an error occured:

    #include<valarray>

    using namespace std;

    main()

    {
    valarray<int> val(10);

    slice_array<int>& v0=val[slice(0,5,2)]; ///aaa
    const slice_array<int>& v1=val[slice(0,5,2)]///bbb

    }

    there aaa and bbb both occured an compiling error:
    error C2248: 'stlp_std::slice_array<_Tp>::slice_array' : cannot access
    private member declared in class 'stlp_std::slice_array<_Tp>'
    I know that slice_array can't be constructed,but why a reference is
    also error?

    aaa is an example in Stroustrup TC++PL 3rd special edition
    bbb is some help i found in the past information in 2001,but they used
    gcc.

    finally i found some solution in MSDN. They used val[slice] directly.I
    have tryed it .And it works well.
    But i still want to know why this problem happened.

    Look forward to your answers.
    Thx
     
    holmescn, Mar 20, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.