您的位置:程序门 -> c/c++ -> c++ 语言



帮帮忙,新手~`


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


帮帮忙,新手~`
发表于:2008-01-23 10:14:57 楼主
//名字装框.cpp
#include   <iostream>
#include   <string>
using   namespace   std;
int   main()
{
cout   < <   "please   enter   your   name:   ";
string   name;
cin   > >   name;
const   string   greeting   =   "hello,   "   +   name   +   "!";
const   string   space(greeting.size(),   '   ');
const   string   second   =   "*   "   +   space   +   "   *";
        ->     const   string   first(second.size(),   "*");               /*不能将参数   1   从“__w64   unsigned   int”转换为“const   std::basic_string <_elem,_traits,_ax>   &”*/
cout < <   endl   < <   first   < <   endl
< <   second   < <   endl
< <   "*   "   < <   greeting   < <   "   *"
< <   second   < <   endl
< <   first   < <   endl;
system("pause");
return   0;
}
为什么这样做错了?
高手指点
小弟初学
发表于:2008-01-23 11:36:151楼 得分:0
弄清楚first的第一个参数的意义再说
发表于:2008-01-23 11:37:402楼 得分:0
const       string       first(second.size(),       "*");                               /*不能将参数       1       从“__w64       unsigned       int”转换为“const       std::basic_string   <_elem,_traits,_ax>       &”*/  
--> 第一個參數的類型不匹配,不能轉換,查一下msdn中對string構造方法的描述就知道了。
发表于:2008-01-23 15:40:263楼 得分:0
msdn.


快速检索

最新资讯
热门点击