Sample
- SHA256
-
35c7442ec7a3c6d8fa57efbc10a0931c009524130aae05ef57bb85dace4cdf6f - Difficulty
- easy
- Platform
- Windows
- Tags
- c++ calling conventions clean
- Likes
- 0
- Views
- 11
- Submitter
- struppigel
Analysis
Goal
Learn how thiscall and C++ constructors looks like based on a small C++ sample.
Description
BMICalculator.exe
I created this sample based on the following code:
#include <iostream>
class Person {
private:
int weight; // in kilograms
int height; // in centimeters
public:
// Constructor
Person(int w, int h) : weight(w), height(h) {}
// Method to calculate BMI
double calculateBMI() const {
double heightInMeters = height / 100.0;
return weight / (heightInMeters * heightInMeters);
}
// Method to check if the BMI is in a healthy range
bool isHealthyBMI() const {
double bmi = calculateBMI();
return bmi >= 18.5 && bmi <= 24.9;
}
// Method to print whether the BMI is healthy or not
void printHealthStatus() const {
if (isHealthyBMI()) {
std::cout << "The BMI is in a healthy range." << std::endl;
} else {
std::cout << "The BMI is outside the healthy range." << std::endl;
}
}
};
int main() {
// Creating a person object with weight 70kg and height 175cm
Person person(70, 175);
// Display BMI and health status
std::cout << "BMI: " << person.calculateBMI() << std::endl;
person.printHealthStatus();
return 0;
}
Recommended Tools
Ghidra
Comments
Please login to view and post comments.