开发者

work with .hpp files

开发者 https://www.devze.com 2023-02-19 21:10 出处:网络
The codes in my main program are given below; here I read a file called test.dat and data of this file put in to my structure so for that I used a class called MyData (my_data.hpp).

The codes in my main program are given below; here I read a file called test.dat and data of this file put in to my structure so for that I used a class called MyData (my_data.hpp).

int main()
{
  // cout<<"this my program"<<endl; // when this delete, this codes are not working
   bool ok=true;
   MyData  my_data("test.dat", ok);   
   if(ok==false){
      cout<<"Error, unable to read file1.";
      return 0;
   }
   ACalculation a_calculation(&my_data);

For the calculation part, I used another class, AClaculation (a_calculation.hpp). Here I used pointers to speedup my program.

ACalculation (MyData  * my_data){
MYData::iterator i;
for (i= my_data ->begin(); i!= my_data ->end(); i++){

if(i->A() > max){
          max = i->A();
          }

}

cout<<”my max value is:”<<max;

My program does not show any errors but when I run it, it does not show the result of my max value. But when I added a “cout” code at the beginning of the main program then it shows the result. It means, when I delete this line:

cout<<""this my program";

the program does not show correct output. But when I add it again, it workq. I can't understand where the error of my program is?.

Please help me to find out my mis开发者_JAVA技巧takes here.. thanks


I think you have to flush the console printing an endl

0

精彩评论

暂无评论...
验证码 换一张
取 消