for (auto room : rooms) explanation? : <p>i'm trying to learn c++.
The problem of this task is to print out the total rent of rooms. The code work fine. but there are something i want to ask:</p>

<p>i don't get this line in the main function: "for (auto room : rooms)", i thought for loop suppose to have ";" ?  and auto syntax has "=" ? 
and do we really need "delete room;" and why?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;

class HotelRoom {
public:
    HotelRoom(int bedrooms, int bathrooms)
            : bedrooms_(bedrooms), bathrooms_(bathrooms) {}

    virtual int get_price() {
        return 50 * bedrooms_ + 100 * bathrooms_;
    }
private:
    int bedrooms_;
    int bathrooms_;
};

class HotelApartment : public HotelRoom {
public:
    HotelApartment(int bedrooms, int bathrooms)
        : HotelRoom(bedrooms, bathrooms) {}

    int get_price() {
        return HotelRoom::get_price() + 100;
    }
};

int main() {
    int n;
    cin &gt;&gt; n;
    vector&lt;HotelRoom*&gt; rooms;
    for (int i = 0; i &lt; n; ++i) {
        string room_type;
        int bedrooms;
        int bathrooms;
        cin &gt;&gt; room_type &gt;&gt; bedrooms &gt;&gt; bathrooms;
        if (room_type == "standard") {
            rooms.push_back(new HotelRoom(bedrooms, bathrooms));
        }
        else {
            rooms.push_back(new HotelApartment(bedrooms, bathrooms));
        }
    }

    int total_profit = 0;
    for (auto room : rooms) {
        total_profit += room-&gt;get_price();
    }
    cout &lt;&lt; total_profit &lt;&lt; endl;

    for (auto room : rooms) {
        delete room;
    }
    rooms.clear();

    return 0;
    }
</code></pre>
