Skip to content

This code demonstrates the usage of classes and multiple files in C++.

Notifications You must be signed in to change notification settings

End-Us3r/improved-barnacle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

improved-barnacle

-main.cpp- This code demonstrates the usage of classes and multiple files in C++. It defines a Rectangle class with member variables width and length, and member functions to set and get these variables, and calculate the area. The main function prompts the user to choose between finding the area or volume, then prompts for user input to calculate the area or volume of a rectangle or box using the Rectangle and Box classes. The program validates the user input to ensure only valid values are used.

-box.cpp- This code defines a C++ class called "Box" with methods to set and retrieve the dimensions of a box (width, length, and height) and calculate its volume. The code includes a header file "box.h", and the "using namespace std" statement is used to avoid typing "std::" before using standard library functions.

The methods in this class are:

setWidthBox: sets the width of the box
setLengthBox: sets the length of the box
setHeightBox: sets the height of the box
getWidthBox: returns the width of the box
getLengthBox: returns the length of the box
getHeightBox: returns the height of the box
getVolume: calculates and returns the volume of the box based on its width, length, and height.

-box.h- This code declares a C++ class named Box that has private data members representing the width, length, and height of a box. It also includes public member functions that allow setting and getting the values of these data members, as well as a function that calculates and returns the volume of the box.

The #ifndef and #define preprocessor directives are used to prevent multiple inclusions of this header file in the same translation unit, ensuring that the class is defined only once.

About

This code demonstrates the usage of classes and multiple files in C++.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages