0
我有一個顯示內容的函數,其中的字符位置可以不同。功能如下:將std :: left作爲參數傳遞
void display(std::ostream & stream, std::ios_base & positioning);
然而,當我嘗試調用這個函數像這樣
display_header(std::cout, std::left);
我收到以下錯誤
error: non-const lvalue reference to type 'std::ios_base' cannot bind to a value of unrelated type 'std::ios_base &(std::ios_base &)'
我不明白爲什麼std::cout
能通過就好,但std::left
拒絕這樣做。 lvalue reference to type 'std::ios_base'
又如何與lvalue reference to type 'std::ios_base'
不同?