@kytcenochka

Ошибки при заполнении вектора. С++?

Куча ошибок. Помогите реализовать
Все ошибки указывают на эту строчку
std::string get() { return name << "," << last_name << "," << year << "\n";}

#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>

using namespace std;
class Student
{ 
public:
    std::string name; 
    std::string last_name; 
    std::string year;

    std::string get() { return name << "," << last_name << "," << year << "\n";}
};

int main(int argc, char* argv[])

{
    Student student;
    student.name="Ivan";
    student.last_name="Ivanov";
    student.year = "2001";
    student.get();

    vector<string> v1;
    v1.push_bask(Student::get);
}
  • Вопрос задан
  • 97 просмотров
Решения вопроса 1
myjcom
@myjcom Куратор тега C++
using namespace std;
class Student
{ 
public:
    string name; 
    string last_name; 
    string year;
    string get() 
    { 
         string s =  name + ',' + last_name + ',' + year;
         return s;
    }
};

int main(int argc, char* argv[])
{
    Student student;
    student.name="Ivan";
    student.last_name="Ivanov";
    student.year = "2001";

    vector<Student> v1;
    v1.push_back(student);
    cout << v1[0].get();
}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы