常乐居

常乐居

6:字符串型和定义类型同义词


include "stdafx.h"
#include 
<iostream>//引用要不std之类的无法使用
#include <string>//字符串型

using std::cout;
using std::endl;
using std::string;//字符串型

int total;
string strsum,strin;

int _tmain(int argc, _TCHAR* argv[])
{
    
int innum;
    strsum
="合计一共;";
    strin
="请输入金额";
    
while(1)
    {
        cout 
<< strsum << total << endl;
        cout 
<< strin << endl;
        cout 
<< tes << endl;
        
if (std::cin >> innum )
        {
            total 
+= innum;
            system(
"cls");
        }
        
else
        {
            cout 
<< "No date" << endl;
        }
    }
        

    typedef 
string str;//typedef 用来定义类型的同义词
    str tes;
    tes
="ookk";

    
return 0;
}




posted on 2009-03-19 10:35  常乐  阅读(239)  评论(0编辑  收藏  举报

导航