Here is a program that demonstrates writing an object to a data file and reading it back: #include <iostream> #include <fstream> using namespace std; class Student { private: string name; int roll; public: void setName(string n) { name = n; } void setRoll(int r) { roll = r; } void display() { cout << "Name: " << name << endl; cout << "Roll: " << roll << endl; } }; int main() { Student s1; s1.setName("John"); s1.setRoll(101); // Writing object to data file ...
This blog is about providing theory as well as simple executable codes of different programming languages such as java, C, C++, and web programming, etc. This blog will be helpful to the IT students to learn about programming.