hafez1
یک شنبه 21 خرداد 1391, 15:21 عصر
این برنامه یه فایل متنی با نام input.txt دارد.که حاوی محتویات زیر است:
hello C++ programmers
به این کدها بنگرید!
#include<iostream>
#include<fstream>
class myfirstclass
{
public:
void greeting();
myfirstclass();
private:
char msg[22];
int loopcounter;
fstream myfile;
};
myfirstclass::myfirstclass()
{
//open the file with the data
myfile.open("input.txt",ios ::in);
myfile.getline(msg,22);
}
void myfirstclass::greeting()
{
cout<<msg<<"\n";
}
int main()
{
myfirstclass myfirstobject;
myfirstobject.greeting()
return 0;
}
اول اینکه یکم توضیح در باره روند کلی برنامه نیاز دارم.
در خط 16 ios::in یعنی چی؟
در خط 17 getline چی کار می کنه؟
ودر آخر :چرا ارور می ده؟؟؟؟؟؟؟؟؟؟؟؟/:متعجب:
hello C++ programmers
به این کدها بنگرید!
#include<iostream>
#include<fstream>
class myfirstclass
{
public:
void greeting();
myfirstclass();
private:
char msg[22];
int loopcounter;
fstream myfile;
};
myfirstclass::myfirstclass()
{
//open the file with the data
myfile.open("input.txt",ios ::in);
myfile.getline(msg,22);
}
void myfirstclass::greeting()
{
cout<<msg<<"\n";
}
int main()
{
myfirstclass myfirstobject;
myfirstobject.greeting()
return 0;
}
اول اینکه یکم توضیح در باره روند کلی برنامه نیاز دارم.
در خط 16 ios::in یعنی چی؟
در خط 17 getline چی کار می کنه؟
ودر آخر :چرا ارور می ده؟؟؟؟؟؟؟؟؟؟؟؟/:متعجب: