No matching constructor for initialization

I get the following error: No matching constructor for initialization 'vector<Ability>'. How could I go about fixing this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Warzone v2
// (c) 2017, all rights reserved

#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <ctime>
#include <tuple>
#include <vector>
#include <array>
#include <valarray>
#include <fstream>
#include <iomanip>
#include <cassert>
using namespace std;

struct Ability {
    string name;
    int level_adder;
    
    int cost(int level, int intelligence) {
        return (level + level_adder) * intelligence;
    }
    
    bool can_afford(int level, int intelligence, int manna) {
        return cost(level, intelligence) <= manna;
    }
    
    void show(int level, int intelligence) {
        std::cout << name << "[" << cost(level, intelligence) << " manna]\n";
    }
};

struct PlayerClass {
    string name;
    vector<Ability> abilities;
    size_t ability_count() { return abilities.size(); }
    
    void show(int level, int intelligence) {
        for (int i=0; i<abilities.size(); i++) {
            std::cout << "[" << i << "] ";
            abilities[i].show(level, intelligence);
        }
    }
    
    Ability const &operator[](size_t index) const {
        return abilities.at(index);
    }
};

class Player {
    PlayerClass &pclass;
    string name; // player name
    int health = 100; // player health
    int mana = 20; // player mana
    int strength = 5; // strength [what it does]
    int intelligence = 5; // intelligence [what it does]
    int agility = 5; // agility [what it does]
    int level = 0; // player level
    int xp = 0; // experence
    int xprequired = 50; // amount of xp is required to level up
    int xpincrease = 25; // increases each level, adds to 'xprequired'
};

// Player Classes
PlayerClass Champion{
    "Champion",
    {"Cleaving Strike", 0},
    {"Melting Thrust", 0},
    {"Critical Bash", 0},
    {"Purify", 1}
};

int main() {
    return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
PlayerClass Champion {
    
    "Champion", // std::string 
    
    { // std::vector<Ability>
    
        { "Cleaving Strike", 0 },
        { "Melting Thrust", 0 },
        { "Critical Bash", 0 },
        { "Purify", 1 }
    }
};


You may want to address the warnings:
http://coliru.stacked-crooked.com/a/121ac52d410b36f6
Topic archived. No new replies allowed.