在Android 中 ,如果一个模板类 A 继承与 模板类 B ,当A 引用B 的共有成员时, 如果不加 “this->” , 会产生“was not declared in this scope”错误

例如:

template <typename T> struct B {  int m;  int n;  int f ();  int g ();};int n;int g ();template <typename T> struct C : B<T> {  void h ()  {    m = 0; // error     f ();  // error     n = 0; // ::n is modified    g ();  // ::g is called  }};

真确的写法是 :

template <typename T> void C<T>::h (){ this->m = 0; this->f (); this->n = 0 this->g (); }
 
官方解释是 :http://gcc.gnu.org/gcc-3.4/changes.html “
In a template definition, unqualified names will no longer find members of a dependent base (as specified by [temp.dep]/3 in the C++ standard)






2. another error : "expected unqualified-id before numeric constant"

用GCC 编译时 , 有时会遇见这个错误信息, 这个错误的可能原因是 代码中的变量 有重复的定义。

更多相关文章

  1. 【Android】- MediaPlayer错误之MediaPlayer start called in st
  2. [Android]编译错误:Could not get unknown property 'release' f
  3. android 细节之An internal error occurred during: "Launching
  4. 我的Android进阶之旅------>解决错误:You need to use a Theme.Ap
  5. android studio 中 java.lang.NoClassDefFoundError:retrofit2.R
  6. Android(安卓)Studio Can not reslove *的解决方案
  7. Android(安卓)添加Library出现错误Error:(2, 0) Plugin with id
  8. vue中判断是iOS,安卓,以及微信的方法
  9. Android(安卓)Listener侦听的N种写法

随机推荐

  1. Android 控件常用属性
  2. JAVA & Android 系统环境变量配置
  3. Android 7.1 去掉桌面上的谷歌搜索框
  4. Android实时获得周围wifi信息(SSID,强度等)
  5. android 塔防游戏汇总 及android 游戏开
  6. 【Android】【Framework】Android_Framew
  7. android图片切换ImageSwichter的动画切换
  8. Android Shape 详解
  9. android热修复--阿里热修复使用和源码分
  10. android 背景图片