Задать вопрос
@MEDOVIK21

Как игнорировать строки и символы при чтении из файла?

Учусь писать на c++ , изучаю перегруз операторов , появилась ошибка , которую я понимаю , но не знаю как починить.
хочу чтобы в фаил записывалось в такой форме как и есть , но нужно чтобы при чтении в файл игнорировались все строки и символы и читались только цифры.
Проект имеет хедэр , и 2 cpp:

//Point.h
#pragma once
#include
#include
#include
#include
using namespace std;

class Point {
private:
int x = 0;
int y = 0;
public:
Point() {};
Point(int x , int y);
Point(Point& Class);
~Point();


bool operator==(Point & other);
friend ostream& operator<<(ostream& output, Point &orher);
friend istream& operator>>(istream& input, Point& other);
};
//PointLogic.cpp
#include "Point.h"
Point::Point(int x, int y) {
this->x = x;
this->y = y;
}
Point::~Point() {

}
bool Point::operator==(Point& other) {
return this->x == other.x && this->y == other.y;
}
ostream& operator<<(ostream& output, Point& other)
{
output << "Точка в координате X = " << other.x << endl;
output << "Точка в координате Y = " << other.y << endl;

return output;
}
istream& operator>>(istream& input, Point& other) {
input >> other.x >> other.y;
return input;
}

// AMC.cpp / main.cpp
#include "Point.h"

int main() {
setlocale(LC_ALL, "Rus");

Point a(2, 22);
Point b(2, 14214);

cout << b;

ofstream file("File.txt");
file << a;
file.close();

ifstream arne("File.txt");
arne >> b;
arne.close();

cout << b;
return 0;
}
  • Вопрос задан
  • 24 просмотра
Подписаться 1 Простой 1 комментарий
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы