c++ - Initializing object to an empty list from a reference parameter -


class listofgifts {    private:        gift list[50];        int count = 0;     public:        void suggest(listofgifts& affordable, float dollarlimit) const        {             // how initialize affordable empty list without constructor        }  } 

trying initialize list parameter reference. how can this?

use std::array:

class listofgifts {    private:        std::array<gift, 50> list;        int count = 0;     public:        void suggest(listofgifts& affordable, float dollarlimit) const        {             affordable.list = std::array<gift, 50>{};        }  } 

fyi, c++ literally built on constructors. come eventually, , they're quite helpful.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -