新的C++編碼,並試圖獲得唯一指針的手。我運行到3個錯誤C++語法和編譯器錯誤 - 操作符不匹配<<
1.cpp|14|error: no match for 'operator<<' 2.cannot bind 'std::basic_ostream<char>' lvalue to std::basic_ostream<char>&&
#include <iostream>
#include <memory>
using std::cout;
using std::cin;
using std::endl;
using std::make_unique;
int main(){
auto ptr = make_unique<int>(4);
cout << "The value of ptr: " << ptr << endl;
cout << "The value of ptr: " << &ptr;
}
您需要取消引用'ptr':'COUT << 「PTR的價值:」 << * PTR << ENDL;' – ildjarn