ALL, I have a following code:
In .h file:
struct Foo
{
int ma;
double mb;
Foo(int a, double b)
{
ma = a;
mb = b;
}
Foo()
{
ma = 0;
mb = 0.0;
}
};
class MyClass
{
public:
MyClass();
private:
std::map<std::string,Foo> m_map;
};
In .cpp file:
MyClass::MyClass()
{
m_map["1"] = Foo( 1, 0.1 );
m_map["2"] = Foo( 2, 0.2 );
m_map["3"] = Foo( 3, 0.3 );
}
What is the easiest way to assign Foo( 0, 0 ) to m_map["2"]?
I can simply write
m_map["2"] = Foo( 0, 0 );
but in this case a new variable of the type Foo will be created.
Also, I don't have a loop and so can't really use iterators...
Thank you.