Reputation: 198 Stalwart
- Active Members
- Active Posts:
- 1,687 (1.01 per day)
- 13-March 10
- Profile Views:
- Last Active:
- Sep 26 2014 03:18 AM
- Dream Kudos:
Posts I've Made
Posted 24 Sep 2014Thanks for the answer. The confusion i guess comes from the fact of too many "*".
So, first question is: does the TYPE between "new" and "[size]" indicate what type the array will hold?
means that we will have an array of type T allocated on the heap?
new int*[size]; new unique_ptr<Person>[size];
means that we will have an array holding (as its elements) values of type int* and unique pointers to Person object on the heap?
If that is the case, why dont we have the syntax:
int* a = new int*[size];
Why do we need the second asterisk as in int**.
Because i believe to dynamically allocate an array of unique pointers we would do:
std::unique_ptr<int>* upa = new std::unique_ptr<int>[size]; (again, not sure if corret)
Hope you can confirm the first question and explain the last one.
Posted 27 Aug 2014Thanks for the answers.
@CTphpnwb - the only reason i used pointers to strings was just to learn how exactly vectors and copy constructors work. I do realize that usually it's not what should be done.
@vividexstance - i am aware of move semantics and smart pointers but for now they are too advanced.
Posted 9 Aug 2014What if you have a Person class and setAge() function and the outside uses it and does:
I never heard of anyone living thousand years. Read about encapsulation.
Posted 1 Aug 2014Why would the constructor that does the following compile:
amount = 0;
What if amount is of type Apples. Can someone explain or is it just an error in the tutorial.
Posted 19 Jun 2014I solved my problem in a different way.
- Member Title:
- D.I.C Lover
- Age Unknown
- Birthday Unknown
- Click here to e-mail me
darek9576 hasn't added any friends yet.