直接上代码:

nl.h

#ifndef NL_H
#define NL_H #include <iosfwd> namespace ZJ
{
/**
Insert a newline character '\n'
without flushing the ostream
*/
std::ostream& nl(std::ostream& os);
} #endif // NL_H

nl.cpp

#include "nl.h"

using namespace std;

ostream& ZJ::nl(ostream& os)
{
return os << '\n';
}

main.cpp

#include "nl.h"

#include <iostream>

using namespace ZJ;
using namespace std; int main()
{
cout << "newlines"<< nl << "between"<< nl
<< "each"<< nl << "word"<< endl;
cout << "................................"; return ;
}

报错:

nl.cpp
src\nl.cpp(7) : error C2676: 二进制“<<”:“std::ostream”不定义该运算符或到预定义运算符可接收的类型的转换

原因:

nl.h中的#include <iosfwd>换成#include <iostream>

ERROR C2676的更多相关文章

  1. could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

    VS2008, 写一个简单的demo的时候出现了这个: 1>------ Build started: Project: GetExportTable, Configuration: Relea ...

  2. C++学习之重载运算符1

    C++除可重载函数之后,还允许定义已有的运算符,这样通过运算符重载可像处理数据使用它们. 先来个代码 #include<iostream> using namespace std; cla ...

  3. C语言常见错误中英文对照表

    C语言常见错误中英文对照表(网络搜索及经验积累不断更新中) 常见错误中英文对照表 fatal error C1003:  error count exceeds number; stopping co ...

  4. STL中map错误用法一例

    [GBK]0G's fans( me ) 13:34:26typedef struct _TX_DATA{ int len; unsigned char buff[0x100]; } TX_DATA, ...

  5. C语言开发中常见报错的解决方案

    C语言开发中常见报错的解决方案 整理来源于网络,侵权请通知删除.*禁止转载 ---- fatal error C1003: error count exceeds number; stopping c ...

  6. C++20初体验——concepts

    引子 凡是涉及STL的错误都不堪入目,因为首先STL中有复杂的层次关系,在错误信息中都会暴露出来,其次这么多类和函数的名字大多都是双下划线开头的,一般人看得不习惯. 一个经典的错误是给std::sor ...

  7. Mediaplayer error (-19,0)

    Android MediaPlayer 发生 error (-19,0) 错误解决方法. 引起原因:由于多次实例化MediaPlayer.start() 进行播放操作引起的.由于没有及时释放内存资源导 ...

  8. 4.Android 打包时出现的Android Export aborted because fatal error were founds [closed]

    Android 程序开发完成后,如果要发布到互联网上供别人使用,就需要将自己的程序打包成Android 安装包文件(Android Package,APK),其扩展名为.apk.使用run as 也能 ...

  9. myeclipse 内存不够用报错PermGen space 和 An internal error has occurred.

    最近项目中又增加了新的模块,项目的代码又多了不少.运行的时候总是报如下错误 Exception in thread "http-apr-80-exec-6" java.lang.O ...

随机推荐

  1. Jenkins环境初步配置

    为研究在kubernetes上的CICD,先在物理环境下安装个JenKins热热身. 安装Jenkins 在官网https://jenkins.io/下载war包,我的是http://mirrors. ...

  2. SQLAlchemy会话与事务控制:互斥锁和共享锁

    关于sqlalchemy,可以细度这个网址:http://www.codexiu.cn/python/SQLAlchemy%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/73 ...

  3. python wheel 包命名规则和 abi 兼容

    wheel 包的命名规定 wheel 包的命名格式为 {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform ...

  4. unity deferred lighting

    不同于硬件的tbdr 软件层把光照放后面计算也有一个tbdr 先说deferred rendering 再说tiled 1.gbuffer出 G0 albedo ---rgb occlusion -- ...

  5. No_16_0324 Java基础学习第二十三天

    文档版本号 开发工具 測试平台 project名字 日期 作者 备注 V1.0 2016.03.24 lutianfei none 登录注冊IO版 例如以下代码仅为UserDaoImpl类文件,其它原 ...

  6. java 过滤器补充

    多个Filter按照在配置文件中配置的filter顺序执行. 在web.xml文件中配置该Filter,使用init-param元素为该Filter配置参数,init-param可接受如下两个子元素: ...

  7. Ubuntu切换root用户权限

    其实方法很简单,就是需要选对自己使用的linux系统,不同分支的系统切换root的方法不一定一样. Ubuntu切换root的方法很简单,首先一档钱管理员命令执行: sudo passwd root ...

  8. iOS exit(),abort(),assert()函数区别

    iOS exit(),abort(),assert()函数区别 exit() 退出程序 abort() 停止程序, assert()检查里面的参数如果为nil抛出异常:

  9. vue vuex 大型项目demo示例

    1.vuex 动态模块配置 import Vue from 'vue' import Vuex from 'vuex' import store from '@/store'; // 使用Vuex插件 ...

  10. Unity3D系列教程--使用免费工具在Unity3D中开发2D游戏 第一节

    声明:   本博客文章翻译类别的均为个人翻译,版权全部.出处: http://blog.csdn.net/ml3947,个人博客:http://www.wjfxgame.com. 译者说明:这是一个系 ...