模板,范围分辨率和g ++ [英] templates, scope resolution and g++

查看:80
本文介绍了模板,范围分辨率和g ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码(作为模板实现的双向链表)会产生一些奇怪的错误。


在Digital Mars C ++(v.8.42)中,代码编译但是我必须添加一些看似多余的模板< typename T>在声明友元函数重载之前<<。

I have some code (a doubly-linked list implemented as a template) which is generating some bizarre errors.

On Digital Mars C++ (v. 8.42) the code compiles but I have to add what seems to be a superfluous template <typename T> right before the declaration of a friend function to overload <<.

展开 | 选择 < span class =codeDivider> | Wrap | 行号

推荐答案

您可以发布更多代码。我不知道DLink2类是否是模板。如果不是私有Node类中的T不能解析。
You might post more of your code. I can''t tell if the class DLink2 is a template or not. If it''s not the T in private Node class can''t be resolved.


展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


试试这个:
Try this:
展开 | 选择 | Wrap | 行号


这篇关于模板,范围分辨率和g ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆