乐呵呵网
  • 首页index
  • 电脑知识pc
  • 手机知识mobile
  • 软件教程soft
  • 编程技术code
  • 生活常识life
  • 常见问答answer
  • 美食之家cate
  • 健身养生keep
  • 吃喝玩乐happy
您的位置:首页常见问答文章内容

c++ - 在写模板类时如何定义指向模板的指针的别名?

浏览:41日期:2023-05-15

问题描述

问题解答

回答1:

template <typename Element>class Node {public: // 加上限定符就好了 typedef Node<Element>* PtrToNode;};int main() { Node<int>::PtrToNode p = new Node<int>; delete p;}回答2:

template <typename Element>class Node {};template <typename Element>using PtrToNode = Node<Element>*;class C {};PtrToNode<C> p;

更多内容见http://en.cppreference.com/w/cpp/language/type_alias

上一条:c++如果我有一个成员变量仅在某个成员函数foo()调用的时候赋值,就不能声明foo()成const?下一条:visual-studio - Visual Studio C++ Console调试过程中,有哪些手段可以将要输入的参数,事先存好读进去,而不用手工敲键盘输入
相关文章:
1. solaris基础和常用知识 (2)2. 为什么矛那里的 <a href=" " 这地方为什么是空的呢 ??3. 为什么总是提示我说Template "movieTemplate" not found,我路径都引对了呀4. <tr valign="top"> 看不懂5. mysql - sphinx查询 "中国" 时也能查询到 "中华人民共和国"6. MySQL"="自动 like7. node.js mysql Cannot find module "net" 和 "tls"和"fs" 的问题8. mysql 使用 join 还是 "," 进行多表查询???9. mysql - 使用hibernate连接数据库时,数据库版本过高不支持关键字"type" ;10. 发现 <li><a href="/index.php">回到前台</a></li>这样回到首页后,不是登录状态
热门推荐
  • $ rootScope$ on与$ scope$ on之间的差异
  • $ rootScope$ on与$ scope$ on之间的差异
  • 1.shell - 关于linux脚本中$变量在字符串“”和‘’中使用的问题
  • 2.regex VS包含。最棒的表演?
  • 3.fontSize问题
  • 4.Tomcat在requestDispatcher#forward()上无限循环。StackOverflowError
  • 5.nginx 本地配置后,输入域名访问,还是显示的nginx的欢迎目录,怎么办
  • 6.Next后面的选择器是否有必要?
  • 7.原生JS和jQuery的一个问题?
  • 8.background-image:url(" ")我的图片在桌面
  • 9.linux - shell脚本中怎么判断发行版?
  • 10.Ubuntu桌面版做服务器和Windows做服务器性能是不是差不多?

网公网安备:皖ICP备2020019022号-8 Copyright ¢ 2020-2025 Powered by V1.8 All Rights Reserved 技术支持:乐呵呵网

声明:本站所有资源以学习为主