【问题标题】:class object equals class pointer object with templates [duplicate]类对象等于带有模板的类指针对象[重复]
【发布时间】:2015-07-08 15:22:50
【问题描述】:

我不知道我的 C++ 课程的问题。

template <typename T> class Array {...};
void main(int argc, char* argv[]) {

Array<int> *a1 = new Array<int>();
Array<int> a2();
a2 = *a1; // <--  
}

在指出的行 (

证明你的答案。

【问题讨论】:

  • 证明你的问题。
  • 您知道您可以编写代码运行它并找出答案。
  • 这个问题没有显示任何研究工作。

标签: c++ templates


【解决方案1】:

d) 编译错误,因为你有令人烦恼的解析:

Array<int> a2(); // Declaration of function which takes no argument and return Array<int>

【讨论】:

  • @TartanLlama 我的错。你是对的。由于 main 被声明为 void,它也会生成错误/警告
猜你喜欢
  • 2017-04-25
  • 2019-10-11
  • 2021-07-25
  • 2014-07-04
  • 1970-01-01
  • 2011-02-12
  • 1970-01-01
  • 2023-02-09
  • 1970-01-01
相关资源
最近更新 更多