伊莉討論區
標題:
請問c++ operator的問題?
[打印本頁]
作者:
0oBnBo0
時間:
2010-4-28 04:54 PM
標題:
請問c++ operator的問題?
本帖最後由 0oBnBo0 於 2010-4-28 05:06 PM 編輯
請問...下面的程式為什麼run不出來呀??
錯誤都出在 " cout<<!a; "這行 但是他寫的錯誤..看不懂呢..
// test.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
#include "stdlib.h"
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
class Str
{
public:
Str();
int operator! ();
private:
string data;
int len;
};
Str::Str(){
cin>>data;
}
int Str::operator!()
{
len=0;
for(int i=0;data[i]!='\0';i++)
len++;
return len;
}
int main(int argc, _TCHAR* argv[])
{
string a;
Str();
cout<<!a;
system("pause");
return 0;
}
複製代碼
作者:
runeray2000
時間:
2010-4-28 06:35 PM
提示:
作者被禁止或刪除 內容自動屏蔽
作者:
0oBnBo0
時間:
2010-4-28 06:45 PM
哦...非常感謝大大的解答~
疑問瞬間消失了..xDD
歡迎光臨 伊莉討論區 (http://a401.file-static.com/)
Powered by Discuz!