编译器抛出警告implicit typename is deprecated,百思不得其解,请大虾指教
from main.cpp:1:
source.template:30: warning: `mytree::bag<Item>::size_type' is implicitly a
typename
source.template:30: warning: implicit typename is deprecated, please see the
documentation for details
source.template:37: warning: `mytree::bag<Item>::size_type' is implicitly a
typename
source.template:37: warning: implicit typename is deprecated, please see the
main.o - 0 error(s), 8 warning(s)
请列位大虾不吝赐教,小弟不胜感激
源文件如下
bag.h
#ifndef _MAIN_BAG
#define _MAIN_BAG
#include <cstdlib>
#include "tree.h"
namespace mytree
{
template <typename Item>
class bag
{
public:
typedef std::size_t size_type;
typedef Item value_type;
//CONSTRUCTORS AND DESTRUCTOR
bag();
bag(const bag& source);
~bag();
//MODIFICATION functions
size_type erase(const Item& target);
bool erase_one (const Item& target);
void insert(const Item& entry);
void operator +=(const bag& addend);
void operator =(const bag& source);
//CONSTANT functions
size_type size() const;
size_type count(const Item& target) const;
private:
tree<Item> *root_ptr;
size_t many_nodes;
};
template <typename Item>
bag<Item> operator +(const bag<Item>& b1,const bag<Item>& b2);
}
#include "source.template"
#endif
source.template
#include <cassert>
#include <cstdlib>
#include <iomanip>
#include <iostream>
namespace mytree
{
template <typename Item>
bag<Item>::bag()
{
root_ptr=NULL;
many_nodes=0;
}
template <typename Item>
bag<Item>::bag(const bag& source)
{
tree_copy(source.root_ptr);
root_ptr=source.root_ptr;
}
template <typename Item>
bag<Item>::~bag()
{
tree_clear(root_ptr);
}
template <typename Item>
bag<Item>::size_type bag<Item>:: size()const
{
return tree_size (root_ptr);
}
template <typename Item>
bag<Item>::size_type bag<Item>:: count(const Item& target) const {
size_type answer;
const tree<Item>* cursor;
answer=0;
cursor=root_ptr;
while (cursor!=NULL)
{
if (target<cursor->data())
cursor=cursor->left();
if(target>cursor->data())
cursor=cursor->right();
while(target==cursor->data())
{
++many_nodes;
cursor=cursor->left();
}
}
if (cursor==NULL)
return many_nodes;
}
template <typename Item>
void bag<Item>::operator =(const bag& source)
{
if (this==&source)
return;
tree_clear(root_ptr);
many_nodes=0;
tree_copy(source.root_ptr);
many_nodes=source.many_nodes;
}
}
相关推荐
MySQL 5.6 中TIMESTAMP with implicit DEFAULT value is deprecated错误
安装MySQL时,有warning: [root@localhost mysql]# scripts/mysql_install_db --user=mysql Installing MySQL system tables...2015-08-13 14:20:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 201
clangwarnings.com:Clang警告及其说明列表
clangwarnings.com:Clang警告及其说明列表
MySQL 5.6 中的 TIMESTAMP 和 explicit_defaults_for_timestamp 参数
主要介绍了MySQL 5.6 中的 TIMESTAMP 和 explicit_defaults_for_timestamp 参数,需要的朋友可以参考下
MySQL数据库innodb启动失败无法重启的解决方法
给大家分享了MySQL数据库innodb启动失败无法重启的解决方法,通过总结自己遇到的问题分享给大家,让遇到同样问题的朋友们可以尽快解决,下面来一起看看吧。
MySQL 5.6 中 TIMESTAMP有那些变化
前段时间,系统MySQL从5.5升级到了5.6,系统出现了大量的异常。大部分异常引起原因是由于TIMESTAMP的行为发生了变化,下面通过此篇文章给大家详解MySQL 5.6 中 TIMESTAMP有那些变化,需要的朋友可以参考下


