CoE 123 Object oriented programming.pdf
2.4 MB
الشرحيات بتأشير الدكتور على الداتا شو
مع تأشيرات من عندي اتوقعها تجي كفراغات او صح وخطأ ليس إلا
مع تأشيرات من عندي اتوقعها تجي كفراغات او صح وخطأ ليس إلا
❤10🔥1💊1
شيئية OOP
مثال عن polymorphism : #include <iostream> using namespace std; class Shape { public: virtual double area() = 0; }; class Circle : public Shape { private: double radius; public: Circle(double r) { radius = r; } double area() { return…
هذا السؤال
بس يكلك سويه بالابستراكشن
هيج يصير
اول يكلك سويه بمفهوم توقع المشاكل ( catch , try , throw )
ايضا سهل
جربوه بطريقكم
بس يكلك سويه بالابستراكشن
هيج يصير
#include <iostream>
using namespace std;
class Shape {
public:
virtual void area() = 0;
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r): radius(r){}
void area() {
cout << "Circle area: "<< 3.14 * radius * radius << endl;
}
};
class Rectangle : public Shape {
private:
double length;
double width;
public:
Rectangle(double l, double w): length(l), width(w) {}
void area() {
cout << "Rectangle area: " << length * width << endl;
}
};
int main() {
Circle circle(5);
Rectangle rectangle(4, 6);
circle.area();
rectangle.area();
return 0;
}
اول يكلك سويه بمفهوم توقع المشاكل ( catch , try , throw )
ايضا سهل
جربوه بطريقكم
❤4🔥1