Запись данных в файл не происходит
CPP:
string randp = "results.txt";
fstream rout;
rout.open(randp, fstream::in | fstream::out);
{
rout << "Random A: " << ar << "\nRandom B: " << br << endl;
}
rout.close();
initialize();
}
H:
#ifndef Scene_h
#define Scene_h
#include <vector>
#include "Shape.h"
#include "Stick.h"
namespace DiskGame
{
const int M = 5, N = 5;
class Scene
{
std::vector<Shape*> shapes;
int button;
float angleX, angleY;
float mouseX, mouseY;
float width, height;
float distZ;
bool finish;
Sticks* disks[6];
float xStep, zStep;
int time;
int sc;
int fields[3][3];
int xFrom, zFrom;
int xTo, zTo;
public:
Scene(float xStep, float zStep);
~Scene();
void on_paint();
void on_size(int width, int height);
void on_mouse(int button, int state, int x, int y);
void on_motion(int x, int y);
void on_special(int key, int x, int y);
void on_timer(int value);
int dificult(int& A, int& B);
private:
void initialize();
void results();
void allocatenum();
bool moveDisk(int xFrom, int zFrom, int xTo, int zTo);
void upDisk(int x, int z);
void downAllDisks();
bool findNearest(int x, int z, int& x1, int& z1);
void shapeArr();
float allocX(int i);
float allocZ(int i);
};
}
#endif
Ответы (1 шт):
Автор решения: Harry
→ Ссылка
Вот это — fstream rout(); — совсем не объявление объекта fstream, как вам кажется, а объявление функции rout, возвращающей объект fstream.
P.S. Если намек непонятен — уберите скобки.

