主题:C++中的小错误
#include <iostream>
using namespace std;
const int n=8;
int main(){
char bin[n];
int x=2,a,dex,i;
cout<<"输入二进制序列:"<<endl;
for(i=n-1;i>=0;i--) cin>>bin[i];
dec=0;
for(i=n-1;i>=0;i--){
a=bin[i]-'0';
dec=dec * x+a;
}
cout<<"二进制序列(";
for(i=n-1;i>=0;i--) cout<<bin[i];
cout<<")的值为:"<<dec<<endl;
return 0;
}
--------------------Configuration: 7 - Win32 Debug--------------------
Compiling...
7.cpp
H:\电脑\vc\MSDev98\MyProjects\7\7.cpp(9) : error C2659: '=' : overloaded function as left operand
H:\电脑\vc\MSDev98\MyProjects\7\7.cpp(12) : error C2296: '*' : illegal, left operand has type 'class std::ios_base &(__cdecl *)(class std::ios_base &)'
Error executing cl.exe.
7.exe - 2 error(s), 0 warning(s)
请指教,这个程序要怎么改正?
using namespace std;
const int n=8;
int main(){
char bin[n];
int x=2,a,dex,i;
cout<<"输入二进制序列:"<<endl;
for(i=n-1;i>=0;i--) cin>>bin[i];
dec=0;
for(i=n-1;i>=0;i--){
a=bin[i]-'0';
dec=dec * x+a;
}
cout<<"二进制序列(";
for(i=n-1;i>=0;i--) cout<<bin[i];
cout<<")的值为:"<<dec<<endl;
return 0;
}
--------------------Configuration: 7 - Win32 Debug--------------------
Compiling...
7.cpp
H:\电脑\vc\MSDev98\MyProjects\7\7.cpp(9) : error C2659: '=' : overloaded function as left operand
H:\电脑\vc\MSDev98\MyProjects\7\7.cpp(12) : error C2296: '*' : illegal, left operand has type 'class std::ios_base &(__cdecl *)(class std::ios_base &)'
Error executing cl.exe.
7.exe - 2 error(s), 0 warning(s)
请指教,这个程序要怎么改正?