Created
April 16, 2023 18:08
-
-
Save arisupriatna14/80f83f41af5c1645040c8358a70688af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Shape { | |
protected: | |
double lebar; | |
double tinggi; | |
public: | |
Shape(double l, double t) { | |
lebar = l; | |
tinggi = t; | |
} | |
}; | |
class Rectangle : public Shape { | |
public: | |
Rectangle(double l, double t) : Shape(l, t) {} | |
double hitungLuas() { | |
return lebar * tinggi; | |
} | |
}; | |
int main() { | |
double lebar, tinggi; | |
std::cout << "Masukkan lebar rectangle: "; | |
std::cin >> lebar; | |
std::cout << "Masukkan tinggi rectangle: "; | |
std::cin >> tinggi; | |
Rectangle rect(lebar, tinggi); | |
std::cout << "Luas Rectangle adalah " << rect.hitungLuas() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment