C ++类-错误:声明“ Base k”冲突

时间:2019-06-09 10:25:18

标签: c++

只想知道,为什么在调用构造函数时会出现冲突的声明错误?

 class Base {
   int a;
   public:
      Base() { a = 50; };
      Base(int a): a(a) {
      }
 };

int main() {
  int k = 20;
  Base(k); // this should create a temp object right??
  // i'm getting foll error "conflicting declaration ‘Base k’" 
  // why does compiler treat it has a declaration??
  return 0;
}

0 个答案:

没有答案