Why does the compiler cannot pass?

Discussion in 'C++' started by fl, Jan 28, 2013.

  1. fl

    fl Guest

    Hi,
    I am compiling the following program below the dot line, which is copied from a website. There are some link errors:

    1> overload_Arrow0.cpp
    1>overload_Arrow0.obj : error LNK2019: unresolved external symbol "public: struct A * __thiscall B::eek:perator->(void)" (??CB@@QAEPAUA@@XZ) referenced in function _main
    1>overload_Arrow0.obj : error LNK2019: unresolved external symbol "public: struct B __thiscall C::eek:perator->(void)" (??CC@@QAE?AUB@@XZ) referenced in function _main
    1>overload_Arrow0.obj : error LNK2019: unresolved external symbol "public: struct C __thiscall D::eek:perator->(void)" (??CD@@QAE?AUC@@XZ) referenced in function _main

    I do not solve this after several trials. What is wrong with the code?

    Thanks a lot.

    .......
    #include <iostream>


    struct A {
    void foo();
    };

    void A::foo()
    {
    ;
    }


    struct B { A* operator->(); };
    struct C { B operator->(); };
    struct D { C operator->(); };

    int main()
    {
    D d;
    d->foo();
    }
    fl, Jan 28, 2013
    #1
    1. Advertising

  2. On 1/28/2013 11:07 AM, fl wrote:
    > Hi,
    > I am compiling the following program below the dot line, which is copied from a website. There are some link errors:
    >
    > 1> overload_Arrow0.cpp
    > 1>overload_Arrow0.obj : error LNK2019: unresolved external symbol "public: struct A * __thiscall B::eek:perator->(void)" (??CB@@QAEPAUA@@XZ) referenced in function _main
    > 1>overload_Arrow0.obj : error LNK2019: unresolved external symbol "public: struct B __thiscall C::eek:perator->(void)" (??CC@@QAE?AUB@@XZ) referenced in function _main
    > 1>overload_Arrow0.obj : error LNK2019: unresolved external symbol "public: struct C __thiscall D::eek:perator->(void)" (??CD@@QAE?AUC@@XZ) referenced in function _main
    >
    > I do not solve this after several trials. What is wrong with the code?


    Just like your linker tells you, it cannot find those functions.

    >
    > Thanks a lot.
    >
    > ......
    > #include <iostream>
    >
    >
    > struct A {
    > void foo();
    > };
    >
    > void A::foo()
    > {
    > ;
    > }
    >
    >
    > struct B { A* operator->(); };
    > struct C { B operator->(); };
    > struct D { C operator->(); };


    The three lines above define classes B, C, D, respectively, and each of
    those classes *declares* operator->() function, but there is no
    *definition* of those functions (B::eek:perator->, etc.) in your code. You
    should consider defining them since you actually call those in your
    'main' program.

    >
    > int main()
    > {
    > D d;
    > d->foo();
    > }
    >


    V
    --
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jan 28, 2013
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RickMuller
    Replies:
    4
    Views:
    693
    Alexey Shamrin
    Mar 26, 2005
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    863
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,762
    Smokey Grindel
    Dec 2, 2006
  4. PerlFAQ Server
    Replies:
    0
    Views:
    578
    PerlFAQ Server
    Feb 11, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    575
    PerlFAQ Server
    Mar 9, 2011
Loading...

Share This Page