Skip to content

TanzeelaFatima492/robert-lafore-cpp-chapter4

Repository files navigation

Robert Lafore C++ Chapter 4 – Program Solutions

This repository contains solutions to all 10 programs from Exercise 4 of the book:
📘 "Object-Oriented Programming in C++" by Robert Lafore.

📚 Programs Covered

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.


🚀 How to Compile and Run

To compile and run an example (e.g., program1.cpp), use:

g++ program1.cpp -o program1
./program1

📁 Folder Structure

robert-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

✅ About the Book

Robert Lafore's book is a staple for learning C++ through a hands-on, example-driven approach. Chapter 4 focuses on:

  • struct and class basics
  • enum usage
  • Object manipulation
  • Intro to encapsulation

🙋‍♀️ Author

Tanzeela Fatima 📍 Kotli AJK 🔗 GitHub Profile 📧 codequeen765@gmail.com


⭐ Star this repo if it helped you, and feel free to fork or contribute!

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages