Visual Studio 2012的预览版(VS2010之后的下一个版本)现已推出.
有谁知道它支持哪些新的C++ 11功能?(我现在无法试一试).
在我找到你们的帮助之前,我花了一个多小时研究这个.我正在使用visual studio 2012,我刚刚安装了更新2.
我有这个构造函数
Lexer::Lexer(istream &source1, ostream& listing1)
:source(source1), listing(listing1)
{
vector<string> tempVec = { 
    "and", "begin", "boolean", "break", "call", "end", "else", "false", "halt",
        "if", "input", "integer", "is", "loop", "not", "null", "newline", "or", "output", "procedure"
        "return", "then", "true", "var"
};
tokenToStringVector = tempVec;
for (int k= 0; k < tokenToStringVector.size(); k++)
{
    string key = tokenToStringVector[k];
    lexemeToTokenMap[key] = Token(k); // Function-style type cast
}
}
我的教授写了标题,我写了代码.我收到这个错误,我无法弄清楚:
1>c:\users\sam\dropbox\compiler project\lexical analyzer\lexer.cpp(8): error C2552: 'tempVec' : non-aggregates cannot be initialized with initializer list …我想知道如何初始化一个std::vector字符串,而不必push_back在Visual Studio Ultimate 2012中使用一堆.
我试过了vector<string> test = {"hello", "world"},但这给了我以下错误:
Error: initialization with '{...}' is not allowed for an object of type "std::vector<std::string, std::allocator<std::string>>
我正在观看MVA关于C++的教程,我在下面提到的代码是由凯特写的而不是我.然而,她似乎没有编译显示任何错误,但在我的情况下,我得到以下错误:
错误1错误C2797:'NamedRectangle :: _ name':成员初始化列表中的列表初始化或非静态数据成员初始化程序未实现c:\ users\abhimanyuaryan\documents\visual studio 2013\projects\kate demos\17 inheritance\inheritance \namedrectangle.h 12 1继承
代码中的第12行来自我的NameRectangle类继承自Rectangle类:
class NamedRectangle :  public Rectangle
{
public:
    NamedRectangle() { }
    NamedRectangle(std::string initial_name, int initial_width, int initial_height)
        : Rectangle{ initial_width, initial_height }, _name{ initial_name } //--> This line
    {}  
std::string get_name() const { return _name; }
private:
    std::string _name;
};
当我std::string从构造函数中删除initial_name以及_name{initial_name}代码编译时.请解释我,不要把我当作经验丰富的高级程序员.我昨天才开始使用C++.