Hi there,
I am trying to make a program, as shown below. I have used a snippet with hello and bye as the program is really very big. Unfortunately I am unable to edit these functions as they are all part of a complex linked list.
I am trying to pass both functions from the class CWrite into a text file however what currently occurs is the second function overwrites the first function (i think). I have genuinly no idea what to do to solve this.
Any help fixing this would be greatly appreciated.
#inlcude <iostream>
#include <fstream>
#include <sstream>
class CWrite
{
public:
int write(std::string name);
int write(std::string name);
};
#include “stdafx.h”
#include “output.h”
int CWrite::write(std::string name)
{
std::ofstream output(name.c_str());
output<<”HELLO”<<std::endl;
output.close();
return 0;
}
int CWrite::write(std::string name)
{
std::ofstream output(name.c_str());
output<<”HELLO”<<std::endl;
output.close();
return 0;
}
Private: System::Void ButOut_Click(System::object^ sneder, System::eventArgs^ e)
{
SaveFileDialog ^ saveFileDialog1 = gcnew SaveFileDialog();
savefileDialog1->Filter = “txt files (*.txt)|*.txt|All files (*.*)|*.*”;
saveFileDialog1->InitialDirectory = “library”;
if(saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::Ok)
{
CWrite a;
std::string std_name = SystemToStdString(saveFileDialog1->FileName);
int success = a.write(std_name) + a.writeSDF(std_name);
}
Please ignore any syntax errors as the code had to be written from Word.
Thanks in advance,
Andy