CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: googler

Page 1 of 26 1 2 3 4

Search: Search took 0.06 seconds.

  1. Re: why visual studio does not optimize constructor in this case

    This one looks ok. :thumb:
  2. Re: why visual studio does not optimize constructor in this case

    Teabix is right. Your suggested optimization in #11 is incorrect, except in limited cases. You've swapped the order of the following 2 events:

    1) The construction of the temporary RVO object...
  3. Replies
    21
    Views
    2,214

    Re: default implementation of assignment operator

    Failure to allocate automatic storage is not guaranteed to throw an exception in ISO C++. It's unspecified behavior. So is failure to allocate static storage. It's only the standard ::operator new...
  4. Replies
    24
    Views
    1,330

    Re: The type of *this

    *this is an lvalue whose type is the type of the class containing the member function in which it appears. Anything you can do with an lvalue of class type you can do with *this.
  5. Replies
    4
    Views
    956

    Re: Order of Operations

    Don't worry about it, str.length() will be evaluated first. && is a short-circuit operator. You're confusing operator precedence with evaluation order. operator precedence determines the...
  6. Replies
    22
    Views
    2,397

    Re: Issue with float variable subtraction

    This won't work. 0.03 is an infinite repeating binary fraction and can't be represented by floats (or doubles).

    This is a better suggestion, which is to display the final result with two digits...
  7. Replies
    16
    Views
    1,376

    Re: template function issue

    This code should print "char const [12]". If it doesn't then it's a bug. Are you using a beta version of VS2008 or release?

    #include <iostream>

    template<size_t size, typename T>
    const char*...
  8. Replies
    16
    Views
    1,376

    Re: template function issue

    Try running this program and tell me what you get

    #include <iostream>

    using std::cout;
    using std::endl;

    int main()
    {
    char a[12];
  9. Replies
    16
    Views
    1,376

    Re: template function issue

    That doesn't seem right. The typeid of arr should be the same as the typeid of "const char [12]". typeid does not detect references, but it certainly should not convert an array to a pointer to an...
  10. Replies
    16
    Views
    1,376

    Re: template function issue

    This doesn't work because function parameters of array type are adjusted to pointer type

    void func(const char arr[12]); // is adjusted to
    void func(const char *arr);

    template<size_t size,...
  11. Replies
    16
    Views
    1,376

    Re: template function issue

    George2, this works because of a feature called template argument deduction. The template function's parameter type is "const T(&)[size]" where T and size are template parameters. The template...
  12. Thread: Using Printf

    by googler
    Replies
    2
    Views
    640

    Re: Using Printf

    For the key line

    cout << setw(5) << (x / y, array[x][y]);it's

    printf("%5d",array[x][y]);The other outputs are simpler.
  13. Replies
    10
    Views
    3,295

    Re: How to sort a single linked list

    I think mergesort is the best sort for linked lists, and AFAIR it's O(N lg N) for singly linked lists. Writing the code for it off the top of your head during an interview is way too complicated, so...
  14. Thread: string buffer

    by googler
    Replies
    47
    Views
    4,087

    Re: string buffer

    It's not ISO-conforming.
  15. Thread: string buffer

    by googler
    Replies
    47
    Views
    4,087

    Re: string buffer

    Which compiler gives you these results? I'm getting "char [12]" for typeid(buf).name(), "char *" for typeid(p).name() and typeid(buf) != typeid(p).
  16. Replies
    11
    Views
    1,161

    Re: constant perplexity

    It's undefined behavior to modify a const object.
  17. Replies
    4
    Views
    1,091

    Re: Can't flip the bits in a pointer

    hFindHandle = (PVOID) ~ (INT_PTR) hFindHandle;
  18. Re: Rolling Bits: What are those functions again?

    See this, .... _rotl16, _rotl8, _rotr16, _rotr8
  19. Replies
    15
    Views
    1,510

    Re: Definitions and Declarations

    All variables have been defined. variables i and k have both been initialized (to zero), but variable j has only been defined but not initialized (it has an unknown value.)

    No.
  20. Replies
    13
    Views
    931

    Re: Question about unions

    The union method does work, but you insist on ignoring CPUWizard.


    class foo
    {
    public:
    union
    {
    struct { int x, y, z; };
    int data[3];
  21. Replies
    21
    Views
    1,985

    Re: Non-Public Destructors

    I wish I had more those, then maybe my place wouldn't be such a mess... :lol:
  22. Replies
    15
    Views
    3,353

    Re: member function pointer to function pointer

    A function declared as extern "C" is required to have the same name-decoration and calling-convention as C functions. A function declared as extern "C++" (the default language-linkage) is required...
  23. Replies
    15
    Views
    3,353

    Re: member function pointer to function pointer

    Yes, I am. Language-linkage like C or C++ covers both name-mangling and calling-convention. A static member function always has C++ linkage. Visual C++ and GCC/linux allow you to convert it to a...
  24. Replies
    15
    Views
    3,353

    Re: member function pointer to function pointer

    If that's what you need to do then the only portable solution is to pass a pointer to a C++ function defined in namespace scope that's declared as extern "C".
    Some implementations will allow you to...
  25. Thread: vector vs int

    by googler
    Replies
    22
    Views
    2,609

    Re: vector vs int

    You don't really need two functions, because the std::sort template can sort both arrays and vectors. Of course, the compiler may generate a different instance of the template for each.
    The array,...
Results 1 to 25 of 645
Page 1 of 26 1 2 3 4





Click Here to Expand Forum to Full Width

Featured