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

Search:

Type: Posts; User: acppdummy

Page 1 of 4 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Thank you everyone for offering to help! I will first try to duplicate the problem with a small example. If that doesn't work then I will zip up the full program and upload. Thanks again!
  2. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Well it's a bit complicated: the function pointer that points to either fn1 or fn2 is used inside another member function of the same class like this:

    (this->*fnptr)()

    and fn1 and fn2 actually...
  3. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Thank you! But I tried both

    public:
    MyClass(): fnptr(&MyClass::fn1){
    ...
    }; and

    public:
    MyClass(): {
    fnptr=&MyClass::fn1;
  4. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Another question: can the assignment be done in the constructor? (to initialize the pointer)

    I tried it but kept getting core dump. :confused:
  5. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Thanks! So if I understand it correctly, when calling from mc1,

    (this->*fnptr)()

    calls

    mc1.fn1

    and
  6. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Wait! When calling the function pointer it is just calling the function pointer, not the actual function. So it's still not clear to me how
    mc1.fn1 and
    mc2.fn1 are distinguished. :confused: Does ...
  7. Replies
    14
    Views
    309

    Re: Member function pointer assignment

    Ah yes. Now I remember another thing the compiler wants me to do is

    (this->*fnptr)(), not just
    fnptr().

    Thank you! :)
  8. Replies
    14
    Views
    309

    Member function pointer assignment

    I have a class with member functions and a pointer like this:


    class MyClass{
    private:
    typedef void(MyClass::*memFnPtr_t) ();
    public:
    memFnPtr_t fnptr;
    void fn1();
    void...
  9. Re: Compiler auto correct uninitialized variable? (gcc does and VC++ doesn't)

    Thanks! Point well taken - I already fixed the code when VC++ did not do the "smart optimization" and exposed the bug. The exercise of looking at the assembly code was just to understand why g++...
  10. Replies
    3
    Views
    866

    NetBeans Linker Order?

    Any NetBeans user out there that knows the trick? Thanks!
  11. The optimizer made the difference!

    Hello all, Thank you very much for the comments. I learned a lot from this forum as always. Here is what I found:

    Using the -S switch I let g++ produce assembly codes for each of the two...
  12. Re: Compiler auto correct uninitialized variable? (gcc does and VC++ doesn't)

    First of all sorry for my stupid comment about g++ having a "bug". I know it is a well built tool.



    I know the binaries are the same because I use BeyondCompare to do binary comparisons. When I...
  13. Re: Compiler auto correct uninitialized variable? (gcc does and VC++ doesn't)

    Thanks for the comments about '/' vs '\\'.

    Now I am still fascinated by the fact that g++ produced identical binaries from codes with different logic. So I made a small example project and tested...
  14. Replies
    4
    Views
    1,714

    Re: link.xxxxx....tlog files OK to delete?

    A related question: There are two huge files "projectname.sdf" and "projectname-xxxxxx.ipch". Can they be disabled or deleted? Thanks!
  15. Re: Compiler auto correct uninitialized variable? (gcc does and VC++ doesn't)

    Thanks! Does MSVC take mixture of '/' and '\\'?
  16. Compiler auto correct uninitialized variable? (gcc does and VC++ doesn't)

    I had a flawed function like this:


    fn(){
    char c;
    if (runFirstTime){
    #ifdef VC
    c='\\';
    #else
    c='/';
  17. Replies
    4
    Views
    4,275

    Re: VC++ 2010 Express Linker library issues

    Well I got a new laptop and the problem came back. I got a bunch of warnings and errors when the IDE tried to link the fltk library:


    Update: I figured it out. The fltk library was compiled with...
  18. stringstream

    I would like to rewrite something like

    sprintf(str, "%d, %.1lf, %.3lf, %.2lf, ...", a, b, c, d, ....)
    to something like

    But is there a way to specify varying precision easily (there are about...
  19. Re: speed of floating point multiplication vs. division

    Does the speed depend on how many bits are shifted? For example would >>16 take longer than >>1 ? Just curious. Thanks!
  20. Re: speed of floating point multiplication vs. division

    Thanks again everyone! :)
  21. Re: speed of floating point multiplication vs. division

    Thank you both! How about integer multiplication vs. shift? For example <<2 vs. *4 ? Thanks!
  22. speed of floating point multiplication vs. division

    Long time ago I heard that the speed of floating point multiplication is much faster than division. Is it still the case today? (On a not very powerful netbook) Thanks!
  23. Re: How to pair/multimap ?

    I have to move the multimap back into the class otherwise different instances of the class share the same multimap and interfere with one another. Now the code looks something like



    class...
  24. Re: How to pair/multimap ?

    OK I hope I am getting close to the right track: failed to find the syntax to call std::mem_fun and confused by std::function and std::bind, I found this:...
  25. Re: How to pair/multimap ?

    Understood. Thank you very much!
Results 1 to 25 of 94
Page 1 of 4 1 2 3 4



HTML5 Development Center

Click Here to Expand Forum to Full Width