Anyone have a clue what would cause the compiler to complain about static members and functions and virtual functions ?

I've written a bunch of stuff with Qt in C++ without this problem. The only new thing is I've overrided a virtual function and created a few static data members and functions.

When I compile, it complains about the code generated by Qt.

Anyone have a clue about what I may be doing wrong?

Recommended Answers

All 3 Replies

I think you are looking for a general answer, but its hard to tell without
seeing the code, so post relevant code, or if small enough, the whole code.

Well I narrowed my problems, of which I solved one of them. Turns out if you don't have any signals/slots and you place "Q_OBJECT" in your code, things screw up.

The other one appears when I assign a value to a static object. So is this correct...

....
{
   ClassName::StaticMemberName = something;
}

Also is there a way I can set things so I don't have to do "ObjectName:: " all the time?
What the general rule with static functions and members when dealling with headers and code files?

Once again I've solved one bug and got another....

So it turns out you need to define static member outside the class definition in the header file, but now I have another bug. Now when I include the header file, the compiler says "multiple definition of ...".

I have this at the top:

#ifndef PGBULB_H
#define PGBULB_H

and this on the bottom:

#endif

Anyone have a clue what I'm doing wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.