Program hangs when using vector::push_back()

This is for a homework assignment. I've never used vectors before, so I decided I would try to learn. I'm creating a vector of classes, where the classes are Students with several attributes. As the user continues to input new students, I would like to add them to the student vector with the vector::push_back() function, but my program is hanging when I do.

Here's what I've got:

main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>
#include<vector>
#include<sstream>
#include"header.h"

int main(){
	//new vector for individual students
	std::vector<Student> studentVector;
	while (true){
		std::cout << "students ";
		std::string input, command, param1, param2, param3, param4, param5;
		std::getline(std::cin, input);
		std::istringstream s(input);
		s >> command >> param1 >> param2 >> param3 >> param4 >> param5;

		//add students
		if (command == "add"){
			Student *newStudent = new Student(param1, param2, param3, param4, param5);
			studentVector.push_back(*newStudent);
                //I also tried this as
                //studentVector.push_back(Student(param1, param2, param3, param4, param5);
                //and got the same result
		}
		if (command == "quit"){
			break;}
	}
}


header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

class Student{
	std::string firstname, lastname, id, classification, course;
public:
	//Visual C++ tells me that this constructor was the next statement to be executed
	Student(std::string param1, std::string param2, std::string param3, std::string param4, std::string param5){
		firstname = param1;
		lastname = param2;
		id = param3;
		classification = param4;
		course = param5;
		std::cout << "made it here\n";
		};
        /**To be used in the future
	std::string callAttribute(int attribute){
		switch (attribute){
			case 1: return firstname;
			case 2: return lastname;
			case 3: return id;
			case 4: return classification;
			case 5: return course;
			default: return" ";

		}
	};*/

};


My program compiles successfully with no errors or warnings. I would appreciate any guidance on this one!

Thanks.
Have you tried stepping at that point and seeing where it goes?
I disabled the breakpoint and it seems to have worked out this issue okay.

Why would that have happened in the first place? I'm pretty new with Visual C++, might the issue be with that and not my program?
Topic archived. No new replies allowed.