CRectangle is declared as friend of CSquare because it is designed to directly access private variables of CSquare. Without being a friendCRectangle::convert(...) couldn't "calculate" width and height.
This way is dangerous because it violates a design principle to hide an objects attributes against direct mutual access. A getter like f.e. int CSquare::get_side() const would be more appropriate.
In class CRectangle: void convert (CSquare a);
Class CSquare declared below, so CRectangle doesn't know anything about it existence. So we made a forward declaration to tell, that such class exist (and it is really a class, not some typedef of something)
Additonally in your example the first const is mandatory because otherwise you couldn't return a reference to an attribute (C++ member variable) out of a const declared method.
If the returned reference wouldn't be declared const anybody could modify the attributes value which in fact would be a modifucation of the object - but this is forbidden by the second const.
Pair basically is a templated struct with two members. Another interpretation that it is pair of variables types. In your case it is iterator of set<int> and bool.
Consider following: std::pair<int, double> students;
you can make first (int) be their grade and second (double) mean of their marks.
And if you sort array, you will not lose relation between grade and marks of specific individual.
hanie.cpp:13:3: error: ‘cout’ is not a member of ‘std’
hanie.cpp:14:13: error: ‘it’ does not name a type
hanie.cpp:14:34: error: expected ‘;’ before ‘it’
hanie.cpp:14:46: error: ‘class std::map<char, int>’ has no member named ‘cend’
hanie.cpp:15:5: error: ‘cout’ is not a member of ‘std’
hanie.cpp:16:3: error: ‘cout’ is not a member of ‘std’