Hi guys,
when i am compile this program it gives error. i am wondering why it is so.. plz help me.
thankx
#include <iostream>
#include <map>
#include <string>
using namespace std;
class ConfigPath
{
public:
ConfigPath()
{
m_name = "VIPIN DAHIYA";
}
~ConfigPath(){}
private:
string m_name;
};
int main()
{
ConfigPath m1;
ConfigPath m2;
map <string, ConfigPath *> name_path;
map <int, ConfigPath *> name_path;
string s1 = "V1";
string s2 = "V2";
name_path.insert(map <string, ConfigPath *>:: value_type(s1 ,m1));
name_path.insert(map <string, ConfigPath *>:: value_type(s2 ,m2));
return 0;
}
map.cpp: In function ‘int main()’:
map.cpp:24: error: conflicting declaration ‘std::map<int, ConfigPath*, std::less<int>, std::allocator<std::pair<const int, ConfigPath*> > > name_path’
map.cpp:23: error: ‘name_path’ has a previous declaration as ‘std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*> > > name_path’
map.cpp:27: error: no matching function for call to ‘std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*>::pair(std::string&, ConfigPath&)’
/usr/include/c++/4.2/bits/stl_pair.h:84: note: candidates are: std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _T2 = ConfigPath*]
/usr/include/c++/4.2/bits/stl_pair.h:80: note: std::pair<_T1, _T2>::pair() [with _T1 = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _T2 = ConfigPath*]
/usr/include/c++/4.2/bits/stl_pair.h:69: note: std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*>::pair(const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*>&)
map.cpp:28: error: no matching function for call to ‘std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*>::pair(std::string&, ConfigPath&)’
/usr/include/c++/4.2/bits/stl_pair.h:84: note: candidates are: std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _T2 = ConfigPath*]
/usr/include/c++/4.2/bits/stl_pair.h:80: note: std::pair<_T1, _T2>::pair() [with _T1 = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _T2 = ConfigPath*]
/usr/include/c++/4.2/bits/stl_pair.h:69: note: std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*>::pair(const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ConfigPath*>&)