【发布时间】:2014-06-12 06:53:31
【问题描述】:
我的程序返回和错误,我不知道为什么。 我该如何解决这个问题?
错误:
错误:无法将 'std::ostream {aka std::basic_ostream}' 左值绑定到 'std::basic_ostream&&'| 错误:初始化 'std::basic_ostream<_chart _traits>& std::operator&&, const _Tp&) 的参数 1 [with _CharT = char; _Traits = std::char_traits; _Tp = Personne]'|
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
struct Personne { int age; int nb_ami; };
int main()
{
std::cout << "Entrer le nom du fichier: " << std::endl;
std::string fileUser{};
std::cin >> fileUser;
std::ofstream(fileUser.c_str());
std::cout << "Quel age avez-vous ?" << std::endl;
std::vector<Personne> tab(1);
std::cin >> tab[0].age;
for (unsigned int i{}; i < tab.size(); i++){
std::cout << tab[i] << std::endl;
}
return 0;
}
【问题讨论】:
-
提供发生此错误的行号真的很有帮助。
-
不应该是Entrez le nom du fichier吗?
标签: c++