vector class c++

vector class c++

// use vector with class

#include<iostream>
#include<vector>

using namespace std;

class Student
{
    public:
    Student(string _name, int _id):name(_name),id(_id)
    {

    }
    ~Student(){ }
    void print()
    {
        cout<<"name: "<<name<<endl;
        cout<<"id:   "<<id<<endl;
        cout<<endl;
    }
    private:
    string name;
    int id;
};

int main()
{
    vector<Student> list;
    string name;
    int id;

    Student *ptr;

    for(int i=0; i<3; i++)
    {
        cout<<"enter name: ";
        cin>>name;
        cout<<"enter id: ";
        cin>>id;

        ptr=new Student(name,id);
        list.push_back(*ptr);
    }

    vector<Student>::iterator iter;

    for(iter=list.begin(); iter!=list.end(); iter++)
    {
        iter->print();
    }

    return 0;
}