求助 我刚开始学C++

来源:百度知道 编辑:UC知道 时间:2024/09/28 09:46:45
#include <iostream>
int main()
{
std::cout<<"我喜欢c++\n";
int x;
std::cin>>x;
std::cout<<x;
return 0;
}
求助 我刚开始学C++ 。可是在视频上刚学个小编程,我的c++不能运行。郁闷我刚学打击啊!!!! 视频上也是这样编程的,为什么到我这里就不能运行了????

你在哪编译的?
VC6对标准支持不好
这程序是没错的
写成这样
#include <iostream.h>
int main()
{
cout<<"我喜欢c++\n";
int x;
cin>>x;
cout<<x;
return 0;
}
换个编译器吧

#include <iostream>
using namespace std;
int main()
{
cout<<"我喜欢c++\n";
int x;
cin>>x;
cout<<x;
return 0;
}

按F7编译
按F5执行

是你的开头有问题,若包含头文件#include<iostream.h>,则其中包含了命名空间std;你包含的是<iostream>,少个.h,所以在#include<iostream>下一行增加using namespace std;就可以了,现在的C++标准是用命名空间,多以最好不要用#include<iostream.h>,而是用
#include<iostream>
using namespace std;

LS的没看见std::吗?
程序没错的
你的编译环境有问题