#include <iostream>

#include <map>
#include <string>
#include <sstream>
#include <time.h>
using namespace std;
class A
{
public:
A()
 {
  cout << "Constructor A() called"<< "\n";
 }
A(int _a, int _b)
 {
	this->a=_a;
	this->b=_b;
  cout << "Constructor A(a,b) called"<< "\n";
 }
 
~A()
 {
  cout << "Destructor ~A()called"<< "\n";
 }
 protected:
	 int a;
	int	b;
 
 
};

class B: public A
{
public:
B()
 {
    cout << "Constructor B()called"<< "\n";
 }
B(int _a, int _b):A(_a,_b)
 {
    cout << "Constructor B(a,b)called"<< "\n";
 }
 
~B()
 {
  cout << "Destructor ~B()called"<< "\n";
 }
	
};


int  sun(void){
	B bb(1,2);
	return 10;
}


typedef struct _test_struct {
	/*
	_test_struct() : id(0), name(""),padrr(NULL){}
        _test_struct(int newId)
        : id(newId), name(""),padrr(NULL){}
        _test_struct(int newId, std::string newName)
        : id(newId), name(newName),padrr(NULL){}
	*/
        _test_struct(int newId = 0, std::string newName ="",char *addr =NULL)
        : id(newId), name(newName),padrr(addr){}
        int id;
        std::string name;
	char  *padrr;
}TestStruct;




int main(void)
{
	int  i=0;
	// std::map<int, char> m = {{1, 'a'}, {3, 'b'}, {5, 'c'}, {7, 'd'}};
	std::map<int, char> m;
	m[1] = 'a';
	m[3] = 'b';
	m[5] = 'c';
	m[7] = '7';
	
	char   sBuf[20];

	char * pBuff=sBuf;
	
	
	
	std::cout << "[" << m[1] << "]\n";
	std::string  ss;

	 i = 5;
	std::string s;
	std::stringstream out;
	out << i;
	s = out.str();

	std::cout << "[" << s << "]\n";
	
	int a=sun();
	std::cout << "[" << a << "]\n";
	/*
	std::map<std::string, TestStruct> oTestStruct;
	oTestStruct["test0"] = TestStruct();
	oTestStruct["test1"] = TestStruct(1,"test1abc");
	oTestStruct["test2"] = TestStruct(2,"test2abc");
	oTestStruct["test3"] = TestStruct(3,"test3abc");
	*/
	
	/*
	std::map<std::string, TestStruct> oTestStruct ={
		{  "test0",   TestStruct()},
		{  "test1",   TestStruct(1,"test1abc")},
		{  "test2",   TestStruct(2,"test2abc")},
		{  "test3",   TestStruct(3,"test3abc")},
	};
	*/
	std::map<std::string, TestStruct> oTestStruct;
	
	oTestStruct["test0"] = TestStruct();
	oTestStruct["test1"] = TestStruct(1);
	oTestStruct["test2"] = TestStruct(2,"test2");
	
	oTestStruct.insert( std::pair<std::string, TestStruct>( "test3", TestStruct(3,"test3",pBuff) ) );
	//oTestStruct["test3"] = TestStruct(3,"test3",pBuff);
	

	for( std::map<std::string, TestStruct>::iterator it = oTestStruct.begin();
			it != oTestStruct.end(); it++){
				
				cout << it->first  << ":"  <<  it->second.id 
				<< "[" <<  it->second.name << "]"  << "\n";
				//<< "[" <<  it->second.padrr << "]" << "\n";
	
	}
	char sSysTime[80];
	time_t   now = time(0);
	struct tm *pTime = localtime(&now);
	strftime( sSysTime, sizeof(sSysTime), "%Y%m%d%H%M%S", pTime);
	printf("[%s]\n",sSysTime);	
	
	return i;
}
