C++11 инициализация списка не работает

Вот мои файлы
screen.h

#ifndef SCREEN_H
#define SCREEN_H


class Screen {
public:
    using pos = std::string::size_type;
    Screen() = default;
    Screen(pos ht, pos wd, char c) : height(ht), width(wd), contents(ht*wd, c) {}
    char get() const { return contents[cursor]; }
    char get(pos r, pos c) const;
    Screen &move(pos r, pos c);

private:
    pos cursor = 0;
    pos height = 0, width = 0;
    std::string contents;
};

inline char Screen::get(pos r, pos c) const {
    pos row = r*width;
    return contents[row + c];
}

inline Screen &Screen::move(pos r, pos c) {
    pos row = r*width;
    cursor = row + c;
    return *this;
}


class Window_mgr {
private:
public:
    std::vector<Screen> screens = { Screen(24, 80, ' ') };

};

#endif

main.cpp

#include <iostream>
#include <string>
#include <vector>

#include "screen.h"

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
    Window_mgr w;
    w.screens.push_back(Screen(24, 80, ' '));

    std::vector<Screen> screens = { Screen(24, 80, ' ') };
}

Проблема в строке инициализации списка внутри Window_mgr class, Компилятор говорит:

"std::vector<Screen,std::allocator<_Ty>>::vector(std::initializer_list<Screen>,const std::allocator<_Ty> &)": 
невозможно преобразовать аргумент 1 из "Screen" в "const std::allocator<_Ty> &" 
d:\users\family\documents\visual studio 2013\projects\consoleapplication\screen\screen.h

Но дело в том, что такая инициализация списка выполняется правильно в двух моих попытках вне класса (см. Main.cpp). Я думал, что это из-за private модификатор, но public не очень помог Не могли бы вы подсказать, пожалуйста, где настоящая проблема? Спасибо!

UPD Я использую компилятор MS VS Expess 2013 и CTP 2013 VC++.

0 ответов

Другие вопросы по тегам