/*编写一个函数,它接受一个指向string对象的引用作为参数,并将该string对象的内容转化成大写,为此可以
使用表6.4描述的函数toupper()。然后编写一个程序,它通过使用一个循环让您能够用不同的输入来测试这个函数
该程序的运行如下:
Enter a string (q to quit):go away
GO AWAY
Enter a string (q to quit):good grief!
GOOD GRIEF!
Enter a string (q to quit):q
Bye.
*/
#include <iostream>
#include <string>
#include <cctype>
void convert(string &str);
int main()
{
 using namespace std;
 string str1;
 cout<<"Enter a string(q to quit):\n";
 cin>>str1;
 if (str1!='q')
 {
  while (str1) 
  {
   convert(str1);
      cout<<str1;
      cout<<"Enter a string(q to quit):\n";
            cin>>str1;
  }
 }
 else
  cout<<"Bye.\n";
 return 0;
}
void convert(string &str)
{
 using namespace std;
 int limit=strlen(str);
 for(int i=0;i<limit;i++)
 {
  if (isalpha(str[i])) 
   toupper(str[i]);
 }
}
编译的时候总是说: 
error C2065: 'string' : undeclared identifier
error C2065: 'str' : undeclared identifier
error C2182: 'convert' : illegal use of type 'void'
我感觉我在使用之前有定义啊,到底是哪里出了问题呢?
 



 
											





 
	    

 
	




 忘记告诉LZ了...using namespace std; 如果在函数,类,结构体等等的外面的话...后面的函数体内不用再用using namespace std;
忘记告诉LZ了...using namespace std; 如果在函数,类,结构体等等的外面的话...后面的函数体内不用再用using namespace std;