Witam mam dziwny problem wszystko działało do momentu wpisania obsługi wyjątków try{}.
#include "my_file.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdexcept>
int main()
{
my_file file( "dane.txt" );
if ( file.is_file_opened() )
{
std::cerr << "Plik nie istnieje" << std::endl;
// return 1;
}
if ( file.is_file_empty() )
{
std::cerr << "Plik jest pusty" << std::endl;
// return 1;
}
try
{
double budget = std::stod( file.add_budget() );
}
catch ( std::invalid_argument)
{
std::cerr << "Dane w pliku nie są liczbami" << std::endl;
}
std::cout << "budrzet na starcie wynosi: " << std::setprecision(2) << budget << std::endl;
return 0;
}
Bez try zmienna budget normalnie się wypisywała a po zastosowaniu try już nie chce. Nie wiem o co chodzi?