ورود

View Full Version : سوال: دلیل بوجود آمدن خطای undeclared identifier چیست؟



sohrabfar
یک شنبه 15 آبان 1390, 11:09 صبح
سلام من با ویژال سی پلاس پلاس کار می کنم ولی وقتی برنامه رو میخوام اجرا کنم این error رو میده
Error 7 error C2065: 'cin' : undeclared identifier
من از using namespase std; هم استفاده کردم بازم درست نشد لطفا راهنمایی کنید
ممنون میشم

cpppro
یک شنبه 15 آبان 1390, 12:19 عصر
سلام
میشه کد برنامه رو هم بزارین.

sohrabfar
یک شنبه 15 آبان 1390, 15:47 عصر
\\class.h
class Analyz
{
public :
void natije();
};



\\class.cpp
#include <iostream.h>

#include "stdafx.h"
#include "class.h"
using namespace std;
using std::cout;
using std::cin;
void Analyz::natije()
{

int pas=0;
int fild=0;
int natij;
int count=1;

while (count<=10)
{
cout <<"1 ya 2";
cin >>natij;
if(natij==1)
pas++;
else
fild++;
count++;
}
if (pas>=8)
cout<<"good";
}

\\analyz.cpp
#include "stdafx.h"
#include "class.h"


int _tmain(int argc, _TCHAR* argv[])
{
Analyz A1;
A1.natije();
return 0;
}
برنامه شامل یک کلاس میشه
البته قبلا من خودم یه بار حلش کردم اما حلا یادم نمیاد چکار کردم
ممنون میشم اگه کمک کنید

cpppro
یک شنبه 15 آبان 1390, 18:04 عصر
سلام دوباره

#include "stdafx.h"
#include"iostream"

using namespace std;

//class.h
class Analyz
{
public :
void natije();
};

//class.cpp

void Analyz::natije()
{
int pas=0;
int fild=0;
int natij;
int count=1;

while (count<=10)
{
cout <<"1 ya 2 : ";
cin >>natij;
if(natij==1)
pas++;
else
fild++;
count++;
}
if (pas>=8)
cout<<"good";
if(fild>=8)
cout<<"not good";
}

int _tmain(int argc, _TCHAR* argv[])
{

Analyz A1;
A1.natije();

int wait=0;
cin>>wait;

return 0;
}

sharif850
دوشنبه 16 آبان 1390, 10:30 صبح
این برنامه چرا اچرا نمیشه در حالی که با کامپایلر های دیگه انچام میشه من یه تازه کارم نه صفر ولی اصلااز visual c++ express edition 2008 سر در نمیارم کداش فرقه یا... کلا یکی منو کمک کنه #include "stdafx.h"
#include"iostream"

int main()
{
cout <<"please help";
return 0;
}

cpppro
دوشنبه 16 آبان 1390, 19:35 عصر
سلام
من الان کامپایل کردم و اجرا شد.
#include "stdafx.h"
#include"iostream"
using namespace std;

int main()
{
cout <<"please help";
int wait=0;
cin>>wait;

return 0;
}