pure virtual functions : warning

pure virtual functions : warning

Post by kuravina.. » Thu, 12 Oct 2000 10:06:09



Hello,

I was trying to compile the following classes:

base :
=======
class man
{
public :
        virtual print()=0;

Quote:};

foo:
=====
class foo  : public base
{
public:
        foo();
        ~foo();
public :
        print(){cout << "print ## foo " << endl;}

Quote:};

foo1:
======
class foo1  : public base
{
public:
        foo1();
        ~foo1();
public :
        print(){cout << "print ## foo1" << endl};

Quote:};

I got the following warning messages:

foo1.o: warning: multiple common of `base
type_info node'
foo.o: warning: previous common is here

This warning is given only if there is a pure
virtual function in the base class. What does the
error message mean & how is it caused?

I am using gcc 2.91.66 on linux 2.2.14.

regards,
--Sunil

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

pure virtual functions : warning

Post by pratik khasnabi » Thu, 12 Oct 2000 04:00:00


you are deriving from class ' base ' which isn't declared anywhere. I
think you should derive foo and foo1 from man.

pratik


> Hello,

> I was trying to compile the following classes:

> base :
> =======
> class man
> {
> public :
>         virtual print()=0;
> };

> foo:
> =====
> class foo  : public base
> {
> public:
>         foo();
>         ~foo();
> public :
>         print(){cout << "print ## foo " << endl;}
> };

> foo1:
> ======
> class foo1  : public base
> {
> public:
>         foo1();
>         ~foo1();
> public :
>         print(){cout << "print ## foo1" << endl};
> };

> I got the following warning messages:

> foo1.o: warning: multiple common of `base
> type_info node'
> foo.o: warning: previous common is here

> This warning is given only if there is a pure
> virtual function in the base class. What does the
> error message mean & how is it caused?

> I am using gcc 2.91.66 on linux 2.2.14.

> regards,
> --Sunil

> Sent via Deja.com http://www.deja.com/
> Before you buy.


 
 
 

pure virtual functions : warning

Post by Ron Natali » Thu, 12 Oct 2000 04:00:00



> Hello,

> I was trying to compile the following classes:

The code provided has serious problems which may or may not be related
to the problem.  Are these the actual modules you tried to compile?

The obvious problems are:
        1.  print needs an explicit return type.
        2.  base isn't defined anywhere but the foo classes derive from it.

 
 
 

pure virtual functions : warning

Post by kuravina.. » Thu, 19 Oct 2000 04:00:00


Hello,

        I am sorry for the error in example. The base class should have been
"class base" rather than "class man".

regards,
--Sunil



> you are deriving from class ' base ' which isn't declared anywhere. I
> think you should derive foo and foo1 from man.

> pratik


> > Hello,

> > I was trying to compile the following classes:

> > base :
> > =======
> > class man
> > {
> > public :
> >         virtual print()=0;
> > };

> > foo:
> > =====
> > class foo  : public base
> > {
> > public:
> >         foo();
> >         ~foo();
> > public :
> >         print(){cout << "print ## foo " << endl;}
> > };

> > foo1:
> > ======
> > class foo1  : public base
> > {
> > public:
> >         foo1();
> >         ~foo1();
> > public :
> >         print(){cout << "print ## foo1" << endl};
> > };

> > I got the following warning messages:

> > foo1.o: warning: multiple common of `base
> > type_info node'
> > foo.o: warning: previous common is here

> > This warning is given only if there is a pure
> > virtual function in the base class. What does the
> > error message mean & how is it caused?

> > I am using gcc 2.91.66 on linux 2.2.14.

> > regards,
> > --Sunil

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.
 
 
 

1. pure v.f. with body (was: pure virtual function Q)

Ron Natalie, Homer Meyer, and Pete Becker,

It's a very interesting point so I hope it is not completely off topic.
As it was written by Ron, mentioned in my previous post and restated by
Homer and Pete, pure virtual function can have a body.
(I even resorted to check it with VC++ - it really does work).

But I dont understand motivation of C++ designers.
Have you applied this feature in *real-world*?
Is not the usage of this feature deprecated?
Is it an example of good-style programming, at last?

Does Java have such a feature? Does C-sharp?

Having an abstract class with implemented pure virtual functions, and having
the qualified calls of them...
It is clear that there were no any "legacy", "compatibility" etc reasons.
So why?

(Besides, I think a lot of C++ programmers think that it's impossible).
(May be I should repost this to comp.lang.c++.std. Please mention it to me
if it should be).

Looking forward for your comments,

Sincerely,

Ruslan Abdikeev
Brainbench MVP for Visual C++
http://www.brainbench.com

2. Dos-programs in a novell network on a windows 98 station

3. Redeclaring virtual and pure virtual functions?

4. weird crash caused by nVidia RAVE drivers?

5. creating abstract objects (was: Re: Virtual and Pure Virtual member functions)

6. MAC Eudora 5.1 Registration

7. Q: Should the compiler warn for pure virtual methods calls within constructor?

8. SonicWall Virus Subscription

9. R6025 (pure virtual function) error with DCOM

10. pure virtual function call (VC++,COM)

11. pure virtual function called?

12. non pure virtual functions , why use tham at all?

13. Help: Pure virtual function called