Course Hero Logo

Numbers (1).cpp - #define _CRT_SECURE_NO_WARNINGS...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 5 pages.

#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include <cstring>#include<string>#include <fstream>#include "Numbers.h"#include "Numbers.h"// intentionalusing namespace std;namespace sdds {Numbers::Numbers() {setEmpty();m_isOriginal = false;}Numbers::Numbers(const char* filename) {setEmpty();m_isOriginal = true;setFilename(filename);m_numCount = numberCount();if (m_numCount == 0 || !load()) {delete[] m_numbers;delete[] m_filename;setEmpty();m_isOriginal = false;}else {sort();}}Numbers::Numbers(const Numbers& num) {setEmpty();m_isOriginal = false;*this = num;}Numbers& Numbers::operator=(const Numbers& num) {if (this != &num) {delete[]m_numbers;m_numbers = nullptr;m_numCount = num.m_numCount;m_numbers = new double[num.m_numCount];for (int i = 0; i < m_numCount; i++) {m_numbers[i] = num.m_numbers[i];}//setFilename(num.m_filename);}else {setEmpty();}return *this;}int Numbers::numberCount() {char x;int noOfLines = 0;ifstream fin(m_filename);
if (fin.is_open()){while (!fin.fail()){x = fin.get();if (x == '\n'){noOfLines++;}}//noOfLines++;// cout << endl << "line: " << noOfLines << endl;}return noOfLines;}bool Numbers::load() {int i = 0;if (m_numCount > 0) {//string x;delete[]m_numbers;m_numbers = nullptr;m_numbers = new double[m_numCount];ifstream fin(m_filename);

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 5 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Summer
Professor
N/A
Tags
Val, Void type, Carriage return, namespace std

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture