为什么我在尝试打印字符串返回时收到编译器错误?

Why am I getting a compiler error when I'm trying to print string return?

本文关键字:编译器 错误 返回 字符串 打印 为什么      更新时间:2023-10-16

我认为这是一个重载运算符错误,但我不明白为什么它假设我正在尝试使用重载运算符。

string Customer::getCustomerName() 
{
    return customerName;
}
string Customer::getCustomerLicense()
{
    return customerLicense;
}
Date* Customer::getCustomerBirthday()
{
    return customerBirthday;
}
void Customer::printCustomerObject()
{
    cout << getCustomerName(); // No operator "<<" matches these operands
}                                 ERROR CODE: E0349

我认为您没有包含标准的字符串标头。
#include <string>