cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
unqiue_prt declartion
unqiue_prt declartion
Dec 20, 2015 at 1:07am UTC
a10e29
(83)
Greetings and salutations! I've declared this:
std::unique_ptr<std::vector<Piece*>> formations;
The idea behind it was that it can hold anything derived from Piece without object slicing. Will that work?
Thanks for your time
Dec 20, 2015 at 1:18am UTC
JLBorges
(13770)
A vector that can hold (pointers to) anything derived from Piece (without object slicing):
std::vector< std::unique_pointer<Piece> > formations ;
// note: Piece must have a virtual destructor
Dec 20, 2015 at 1:53am UTC
a10e29
(83)
I'm laughing at myself. Thank you my friend
Topic archived. No new replies allowed.