Szablon <map> Visual Studio 2010

0

Witam, mam program w VS 2010 gdzie przy próbie kompilacji w linii

map<string,int> whereis;

wyrzuca błedy

1>TSP_console.cpp(22): error C2143: syntax error : missing ';' before '<'
1>TSP_console.cpp(22): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Ta sama linia w dev c++ kompiluje się poprawnie. Co jest nie tak?

W obu programach załączone zostały biblioteki <string> i <map>

0

std::map<std::string, int>

0

u mnie na domyslnym projekcie konsolowym

#include "stdafx.h"

#include <iostream>
#include <map>
#include <cstring>

using namespace std;

int main()
{
    map <string,int> x;
    return 0;
}

Taki kod przechodzi bez problemu

0

Problem był z przestrzenią nazw. Już sobie poradziłem. Ale mam inny problem przy wstawianiu pary klucz wartość

 whereis["ab"] = 32;

Wyrzuca mi masę błędów, a wedłu http://pl.wikipedia.org/wiki/Tablica_asocjacyjna powinno być dobrze;

0
#include "stdafx.h"
#include "time.h"
#include <map>
#include <iostream>
#include <cstring>


using namespace std;

map<string,int> whereis;

void asoarray(){


	whereis["ab"]=42;

                    }
 

Błędy:

1>TSP_console.cpp(115): error C2440: '=' : cannot convert from 'std::_Tree_iterator<_Mytree>' to 'int'
1> with
1> [
1> _Mytree=std::_Tree_val<std::_Tmap_traits<std::string,int,std::lessstd::string,std::allocator<std::pair<const std::string,int>>,false>>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

0

Pomyłka, to jeden błąd :D

0

W devie się kompiluje bez problemu

pomyliłem się, problem był niżej. Już wszystko gra,dzięki

1 użytkowników online, w tym zalogowanych: 0, gości: 1