vc6.0不知道怎么iostream.h与string形式无法使用,用iostream却可以
比如#include<iostream>
#include<string>
using namespace std;
class A
{private:string r;
public:A(string a)
{r=a;}
void print()
{cout<<r<<endl;}
};
int main(){
A ob("1");
ob.print();
return 0;}可以
但是改头文件
#include<iostream.h>
#include<string>
class A
{private:string r;
public:A(string a)
{r=a;}
void print()
{cout<<r<<endl;}
};
int main(){
A ob("1");
ob.print();
return 0;}
发生错误d:\program files (x86)\microsoft visual studio\myprojects\wqd\wq.cpp(4) : error C2146: syntax error : missing ';' before identifier 'r'
d:\program files (x86)\microsoft visual studio\myprojects\wqd\wq.cpp(4) : error C2501: 'string' : missing storage-class or type specifiers
d:\program files (x86)\microsoft visual studio\myprojects\wqd\wq.cpp(4) : error C2501: 'r' : missing storage-class or type specifiers
d:\program files (x86)\microsoft visual studio\myprojects\wqd\wq.cpp(5) : error C2629: unexpected 'class A ('
d:\program files (x86)\microsoft visual studio\myprojects\wqd\wq.cpp(5) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
d:\program files (x86)\microsoft visual studio\myprojects\wqd\wq.cpp(11) : error C2440: 'initializing' : cannot convert from 'char [2]' to 'class A'
No constructor could take the source type, or constructor overload resolution was ambiguous