Arslan Arslan - 24 days ago 8
C++ Question

Error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'void')|

I am currently learning c++. while doing an example I encountered this error. I don't understand what am I doing wrong here.

#include "people.h"
#include <iostream>
using namespace std;

people::people(string n, birthday obj3)
: name(n), obj2(obj3)


void people::PrintValue(){
cout << name << "was born on " << obj2.PrintDate() << endl; // error line

Answer Source

I assume that your "PrintDate" function is a function that prints the date inside its definition. void means that the expression obj2.PrintDate() does not represent any valid value and therefore you should call the function somewhere beside cout << line.