Re: string

From: hangaround (anonymous_at_discussions.microsoft.com)
Date: 02/23/05


Date: Tue, 22 Feb 2005 19:32:24 -0800


>-----Original Message-----
>hangaround wrote:
>> const char *a = "11";
>> std::bitset<8> header(std::string(a));
>
>Other than what you (and many others) might expect, this
does _not_ create a
>bitset but declares a function called 'header' that takes
a std::string and
>returns a std::bitset<8>. Yes, local functions are not
part of C or C++,
>but local function declarations are.
>
>This is a popular mistake, workarounds are e.g.
>
> std::bitset<8> header((std::string(a)));
> std::bitset<8> header(static_cast<std::string>(a));
> std::bitset<8> header = std::bitset<8>(std::string(a));
>
>> Why the code above couldnot be compiled?
>
>What error message do you get? Next time, try to give
more info!
>
>Uli
>
>.
>

std::bitset<8> header((std::string(a)));
This workaround doesn't work!
VC complains as following:
Compiling...
main.cpp
E:\VcProject\CodeForRead\Experience\Try\main.cpp(8) :
error C2061: syntax
error : identifier 'a'
E:\VcProject\CodeForRead\Experience\Try\main.cpp(8) :
error C2066: cast to
function type is illegal
E:\VcProject\CodeForRead\Experience\Try\main.cpp(8) :
error C2059: syntax
error : ')'
E:\VcProject\CodeForRead\Experience\Try\main.cpp(9) :
error C2065: 'header'
: undeclared identifier
E:\VcProject\CodeForRead\Experience\Try\main.cpp(9) :
error C2228: left of
'.size' must have class/struct/union type
E:\VcProject\CodeForRead\Experience\Try\main.cpp(11) :
error C2109:
subscript requires array or pointer type
Error executing cl.exe.

main.obj - 6 error(s), 0 warning(s)



Relevant Pages

  • Re: TRUE and FALSE values in the relational lattice
    ... E * E: natural join ... the relation with empty header and a single empty tuple ... the equality relation with header ... So the syntax becomes: ...
    (comp.databases.theory)
  • Re: Reading compressed files
    ... (especially unix compress). ... HEADER BODY and FOOTER by open function. ... What you need to do is research each syntax and ...
    (comp.lang.python)
  • Re: RFC: cleaning up the in-kernel headers
    ... Much of the compile time is from just parsing the things ... if a header only needs a structure to be declared because it ... declares that structure fully, just doing a ... anything that actually needs to look past the pointer will need ...
    (Linux-Kernel)
  • RE: .enable detail on a subform?
    ... I seldom use Headers in forms, so my syntax here might be ... I was expecting the FF_FindingTitle is ... > The Option box is in the header of the form. ... >>> When I click on the option group, the text box is not visible, yet the code ...
    (microsoft.public.access.forms)
  • RE: how to declare optional arguments in a udf or sub?
    ... Declares the name, arguments, and code that form the body of a Function ... The Function statement syntax has these parts: ... nor can a Friend procedure be late bound. ... Explicitly declare variables to avoid this kind of conflict. ...
    (microsoft.public.access.modulesdaovba)