主题:菜鸟小问题 VC2005
程序如下:Visual studio 2005中 VC++环境下
#include "stdafx.h"
#include <iostream>
//Function prototypes
bool SayHello(char* szTo, int nCalc);
void SayGoodbye();
//Constants
#define NUMERO_UNO 1
const char* OLD_FRIEND = "old friend, for now.";
int _tmain(int argc, _TCHAR* argv[])
{
char* szCpp = "C++!"; //Declare a variable.
//Call a function with a Boolean result.
if(SayHello(szCpp,2))
{
//Call a function with no result.
SayGoodbye();
}
return 0;
}
bool SayHello(char* szTo, int nCalc)
{
//Use an iostream object for output.
cout<<"Hello,"<<szTo<<"You're Number "<<NUMERO_UNO<<".\n";
return(nCalc + (nCalc*2))<(24/nCalc);
}
void SayGoodbye()
{
cout<<"Bye, "<<OLD_FRIEND<<endl;
}
编译后提示的错误信息:
1:error C2065: 'cout' : undeclared identifier
2:error C2065: 'endl' : undeclared identifier
问题:
1、头文件iostream中不是已经定义了cout 和 endl了吗?怎么还有这样的错误呢?
2、VC2005中的主函数int _tmain(int argc, _TCHAR* argv[])中的_tmain与以前的版本有什么区别吗?
多谢各位大虾的帮助!Thanks a lot!
#include "stdafx.h"
#include <iostream>
//Function prototypes
bool SayHello(char* szTo, int nCalc);
void SayGoodbye();
//Constants
#define NUMERO_UNO 1
const char* OLD_FRIEND = "old friend, for now.";
int _tmain(int argc, _TCHAR* argv[])
{
char* szCpp = "C++!"; //Declare a variable.
//Call a function with a Boolean result.
if(SayHello(szCpp,2))
{
//Call a function with no result.
SayGoodbye();
}
return 0;
}
bool SayHello(char* szTo, int nCalc)
{
//Use an iostream object for output.
cout<<"Hello,"<<szTo<<"You're Number "<<NUMERO_UNO<<".\n";
return(nCalc + (nCalc*2))<(24/nCalc);
}
void SayGoodbye()
{
cout<<"Bye, "<<OLD_FRIEND<<endl;
}
编译后提示的错误信息:
1:error C2065: 'cout' : undeclared identifier
2:error C2065: 'endl' : undeclared identifier
问题:
1、头文件iostream中不是已经定义了cout 和 endl了吗?怎么还有这样的错误呢?
2、VC2005中的主函数int _tmain(int argc, _TCHAR* argv[])中的_tmain与以前的版本有什么区别吗?
多谢各位大虾的帮助!Thanks a lot!