This repository contains solutions to all 10 programs from Exercise 4 of the book:
📘 "Object-Oriented Programming in C++" by Robert Lafore.
| Program No. | Description |
|---|---|
| Program 1 | Demonstrates basic struct usage |
| Program 2 | Adds two distance values using struct |
| Program 3 | Uses cin and cout with structures |
| Program 4 | Manipulates multiple structure variables |
| Program 5 | Uses enum for day-of-week handling |
| Program 6 | Adds two time values using structures |
| Program 7 | Demonstrates floating-point structure usage |
| Program 8 | Uses classes instead of structures |
| Program 9 | Adds two distances using classes |
| Program 10 | Time addition using class methods |
📌 Each program reflects practical applications of structures, enums, and basic class concepts, setting a strong foundation for object-oriented thinking.
To compile and run an example (e.g., program1.cpp), use:
g++ program1.cpp -o program1
./program1robert-lafore-cpp-chapter4/
├── program1.cpp
├── program2.cpp
├── program3.cpp
├── program4.cpp
├── program5.cpp
├── program6.cpp
├── program7.cpp
├── program8.cpp
├── program9.cpp
├── program10.cpp
└── README.md
Robert Lafore's book is a staple for learning C++ through a hands-on, example-driven approach. Chapter 4 focuses on:
structandclassbasicsenumusage- Object manipulation
- Intro to encapsulation
Tanzeela Fatima 📍 Kotli AJK 🔗 GitHub Profile 📧 codequeen765@gmail.com
⭐ Star this repo if it helped you, and feel free to fork or contribute!