3. What does it means?... Does it have any effect about my problem? |
Yo do declare that the Point is a
friend
of Polygon. Why do you do so?
(It does not relate to this problem, but if you do things that you don't understand at all, then you do have a an additional problem.)
About the example, how can I add points without dinamic memory management? |
1 2 3 4 5
|
int main() {
std::vector<int> foo;
foo.push_back( 42 );
return 0;
}
|
Q: Do
we do dynamic memory management in the program above?
A: No. No
new
or
delete
anywhere.
Q: Where does the number go then?
A: To dynamically allocated memory.
Q: Wait! I said we don't?
A:
We don't, but the std::vector does, in its constructor, push_back() and destructor.
the three rules.... do they not exist for me? |
The rule (or guideline) does apply to everyone.
https://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29
However, the rule says what has to be taken care of and if you do use std::vector, you do take care of the problem, because you use components that take care of what the rule says.