新的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