Exercise 1: Calculating Area
Calculate the area of a triangle by using classes.
We'll cover the following
Problem statement
Write a class Triangle
that contains two public float
data members, length
and height
, a public constructor that initializes these data members to 0
and a public member function area
that calculates the area of the triangle and returns it.
Sample input
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy