A simple C++ project that demonstrates file reading and writing using the Singleton design pattern.
This project provides a basic example of file input and output in C++.
It uses the Singleton design pattern to ensure that only one instance of the FileReaderWriter class exists throughout the program.
The class supports:
- Writing text to a file
- Reading text from a file
- Implemented in C++
- Uses the Singleton design pattern
- Simple file read/write operations
- Beginner-friendly example
The FileReaderWriter class includes:
-
getInstance()
Returns the single instance of the class -
write(fileName, content)
Writes content to a file -
read(fileName)
Reads content from a file
Hello Coders!- The program gets the single instance of
FileReaderWriter - It writes
"Hello Coders!"intotestFile.txt - It reads the content from the same file
- It prints the result to the console
- C++ compiler
- Standard C++ library
- Save the code in a
.cppfile - Compile it using a C++ compiler:
g++ main.cpp -o app