Answer the question
In order to leave comments, you need to log in
Errors while filling the vector. C++?
A bunch of mistakes. Help implement
All errors point to this line
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);
}
Answer the question
In order to leave comments, you need to log in
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();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question