关于cout的使用
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
class Teacher
{
public:
void teach();
};
void Teacher::teach()
{
cout<<"good morning!"<<endl;
}
int main()
{
Teacher t;
coutl<<t.teach()<<endl;//注意这里t.teach的使用,如果我把teach的类型改成int型,是可以使用的,为什么?
system("pause");
return 0;
}
-----------------------------------
一下是更改后可正常运行的代码
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
class Teacher
{
public:
int teach();
};
int Teacher::teach()
{
cout<<"good morning!"<<endl;
return 0;
}
int main()
{
Teacher t;
cout<<t.teach()<<endl;//注意这里t.teach的使用,如果我把teach的类型改成int型,是可以使用的,为什么?
system("pause");
return 0;
}