// numstring.h: interface for the numstring class.
 //
 //////////////////////////////////////////////////////////////////////
 #if !defined(AFX_NUMSTRING_H__048C9920_CE10_44AE_A84E_75D2240FCE35__INCLUDED_)
 #define AFX_NUMSTRING_H__048C9920_CE10_44AE_A84E_75D2240FCE35__INCLUDED_
 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 #include "isstring.h"
 class numstring : public isstring
 {
 public:
                   void operator =(const char* psz);
                   numstring(const char* psz);
                   virtual ~numstring();
 };
 #endif // !defined(AFX_NUMSTRING_H__048C9920_CE10_44AE_A84E_75D2240FCE35__INCLUDED_)
 // numstring.cpp: implementation of the numstring class.
 //
 //////////////////////////////////////////////////////////////////////
 #include "stdafx.h"
 #include <assert.h>
 #include "numstring.h"
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 numstring::numstring(const char* psz)
 {
                   (*this).operator =(psz);
 }
 numstring::~numstring()
 {
 }
 void numstring::operator =(const char* psz)
 {
                   string numstr(psz);
                   string integer(numstr);
                   string::size_type at = numstr.find_first_of(".");
                   if(string::npos == at) at = numstr.size();
                   while(at > 3)
                   {
                                     numstr.insert(at - 3 , ",");
                                     at -= 3;
                   }
                   assign(numstr);
 }
  
댓글
댓글 쓰기