error: forming reference to void

The mistake is like the below picture:

The reason is Instantiation Object then call function, but displayMessage() function include cout function. After load this wrong, repair the Codes like the below picture:

The output result:

Good Luck!! I hope the answer could help you solve this problem.

相关推荐
CheerWWW2 小时前
C++学习笔记——this关键字、对象生命周期(栈作用域)、智能指针、复制与拷贝构造函数
c++·笔记·学习
lucky九年2 小时前
GO语言模拟C++封装,继承,多态
开发语言·c++·golang
漫随流水2 小时前
c++编程:D进制的A+B(1022-PAT乙级)
数据结构·c++·算法
tankeven2 小时前
HJ159 没挡住洪水
c++·算法
charlie1145141913 小时前
嵌入式C++教程实战之Linux下的单片机编程:从零搭建 STM32 开发工具链(5):调试进阶篇 —— 从 printf 到完整 GDB 调试环境
linux·c++·单片机·学习·嵌入式·c
paeamecium3 小时前
【PAT】 - Course List for Student (25)
数据结构·c++·算法·pat考试
小黄人软件3 小时前
MFC为什么不报空指针异常 2宏定义不改源码 用替换 用Log函数替换printf等 #define printf Log 优化版底层类Log显示
c++·mfc
漫随流水3 小时前
c++编程:说反话(1009-PAT乙级)
数据结构·c++·算法
计算机安禾4 小时前
【数据结构与算法】第23篇:树、森林与二叉树的转换
c语言·开发语言·数据结构·c++·线性代数·算法·矩阵
ab1237684 小时前
C++ size() 与 length() 核心笔记
开发语言·c++·笔记