C++ "error: "object missing in reference to ..." depends on gcc version -


I am facing a compilation error with a GCC version (4.3.2), while the same code A new version of GCC, eg 4.5.2, will be compiled without complaining.

The following example shows the problem:

  class base {protected: int member; }; Template & lt; Typename T & gt; Class A: Public base {}; Template & lt; Typename T & gt; Class C: Public A & LT; T & gt; {C () {base :: member = 1; }}; IT is getting IT for 4.3.2:  
  test.cpp: constructor in C  

4.5 It compiles for .2 okay.

If a compiler accepts the version code it can not be completely wrong. My guess is that it is consistent with C ++ standards, but the old compiler lacked a proper implementation of the same.

  1. What is the problem really?
  2. Is there a portable way to write code like this, as many compilers accept it as much as possible?

This is definitely a bug in the first version of G ++, but the solution Simplified: simply add this-> expression, as this-> base :: member = 1; which unfreeze compiler


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -