When do you want to use a dynamically allocated object such as, https://leetcode.com/problems/design-twitter/,
- Your Twitter object will be instantiated and called as such:
- Twitter* obj = new Twitter();
- obj->postTweet(userId,tweetId);
- vector param_2 = obj->getNewsFeed(userId);
- obj->follow(followerId,followeeId);
- obj->unfollow(followerId,followeeId);
[ie pointer to a new object]
or a (static?) object such as, https://leetcode.com/problems/flatten-nested-list-iterator/:
- Your NestedIterator object will be instantiated and called as such:
- NestedIterator i(nestedList);
- while (i.hasNext()) cout << i.next();
[ie standard object initialization]