I declare a function that is virutal without implementation code in my base
class, the derived class does not implement it so link error occurs. My
question is how do you make the base class code swung into action?

class A
{
virtual int Run(void);
};


class B : public A
{
want to use class A's code, what can be done?
Thanks
Jack

Re: Declaration and Definition by Jacky

Jacky
Mon Apr 18 14:19:03 CDT 2005

Sorry, Said the wrong thing, the first sentence should turn to "with
implementation code" in place of "without"
Jack

"Jacky Luk" <jl@knight.com> ¼¶¼g©ó¶l¥ó·s»D:%235z9EtERFHA.576@TK2MSFTNGP15.phx.gbl...
>I declare a function that is virutal without implementation code in my base
>class, the derived class does not implement it so link error occurs. My
>question is how do you make the base class code swung into action?
>
> class A
> {
> virtual int Run(void);
> };
>
>
> class B : public A
> {
> want to use class A's code, what can be done?
> Thanks
> Jack
>
>
>



Re: Declaration and Definition by Victor

Victor
Mon Apr 18 14:21:50 CDT 2005

Jacky Luk wrote:
> I declare a function that is virutal without implementation code in my base
> class, the derived class does not implement it so link error occurs. My
> question is how do you make the base class code swung into action?

What code? If there is no implementation, which code will "swing into
action" when you "make it"? Define the function, then there will be
something that will "swing".

>
> class A
> {
> virtual int Run(void);
> };
>
>
> class B : public A
> {
> want to use class A's code, what can be done?

Not sure what you mean here.

Give your function a body. Define it anywhere you want. Just link that
module in after compiling it.

V

Re: Declaration and Definition by Victor

Victor
Mon Apr 18 14:37:24 CDT 2005

Jacky Luk wrote:
> Sorry, Said the wrong thing, the first sentence should turn to "with
> implementation code" in place of "without"
> Jack
>
> "Jacky Luk" <jl@knight.com> ¼¶¼g©ó¶l¥ó·s»D:%235z9EtERFHA.576@TK2MSFTNGP15.phx.gbl...
>
>>I declare a function that is virutal without implementation code in my base
>>class, the derived class does not implement it so link error occurs.

OK, considering your correction, it's

"I declare a function that is virutal with implementation code in my base
class, the derived class does not implement it so link error occurs."

, right? What link error? Post complete code that you think produces
the "link error".

> [..]

V