شيئية 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…
نفس فكرة وطريقة الملزمة :
#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 3.14 * radius * radius;
}
};
class Rectangle : public Shape {
private:
double length;
double width;
public:
Rectangle(double l, double w): length(l), width(w) {}
double area() {
return length * width;
}
};
int main() {
Shape *Shape;
Circle circle(5);
Rectangle rectangle(4, 6);
Shape = &circle;
cout << "Area in Circle : " << Shape->area() << endl;
Shape = &rectangle;
cout << "Area in Rectangle : " << Shape->area() << endl;
return 0;
}
👍3❤1
شيئية OOP
سؤال مختبر البرمجة بتاريخ: 2024/4/20
#include <iostream>
using namespace std;
class cakestore{
public:
virtual void print()
{
cout<< "this is cake store"<<endl;
}
};
class chocolate: public cakestore {
public:
void print() {
cout<< "chocolate cake" << endl;
}
};
class vanilla: public cakestore {
public:
void print() {
cout<< "vanilla cake" << endl;
}
};
int main() {
chocolate typechocolate;
typechocolate.print();
vanilla typevanilla;
typevanilla.print();
/*
cakestore *caketype;
chocolate typecake;
caketype = &typecake;
caketype->print();
vanilla typevanilla;
caketype = &typevanilla;
caketype->print();
*/
return 0;
}
❤5👍1
تجمع بؤساء الهندسة²⁴⁻²³
تغيير قيمة المعاملات باستخدام البوينتر : #include <iostream> using namespace std; int p ( int *ptr){ *ptr+= 1; return *ptr; } int main() { int m = 5; cout << p(&m) << endl; cout << m << endl; cout << p(&m) << endl; }
منا وانت نازل مادتنا لهذا الكورس :
أمثلة
الكوز
اسئلة المختبر
ال18 سؤال
اسئلة من العام السابق
و بالنسبة لشروحات المادة ف اليوتيوب مليئ بالمقاطع تابع الي تفهم عليه
+انا ناشر لعادل نسيم :
في نهاية القائمة ( بوينتر، رفرنس، ستركت، Inline ) :
https://youtube.com/playlist?list=PLCInYL3l2AajFAiw4s1U4QbGszcQ-rAb3&si=3vYmdgld5-Dwv_UF
شرح لـ OOP :
https://youtube.com/playlist?list=PLCInYL3l2Aaiq1oLvi9TlWtArJyAuCVow&si=RPVhIKrXhbp-a8Il
أمثلة
الكوز
اسئلة المختبر
ال18 سؤال
اسئلة من العام السابق
و بالنسبة لشروحات المادة ف اليوتيوب مليئ بالمقاطع تابع الي تفهم عليه
+انا ناشر لعادل نسيم :
في نهاية القائمة ( بوينتر، رفرنس، ستركت، Inline ) :
https://youtube.com/playlist?list=PLCInYL3l2AajFAiw4s1U4QbGszcQ-rAb3&si=3vYmdgld5-Dwv_UF
شرح لـ OOP :
https://youtube.com/playlist?list=PLCInYL3l2Aaiq1oLvi9TlWtArJyAuCVow&si=RPVhIKrXhbp-a8Il
❤3
شيئية OOP
منا وانت نازل مادتنا لهذا الكورس : أمثلة الكوز اسئلة المختبر ال18 سؤال اسئلة من العام السابق و بالنسبة لشروحات المادة ف اليوتيوب مليئ بالمقاطع تابع الي تفهم عليه +انا ناشر لعادل نسيم : في نهاية القائمة ( بوينتر، رفرنس، ستركت، Inline ) : https://youtub…
#include <iostream>
using namespace std;
class Box {
private:
double length;
double breadth;
double height;
public:
Box(double l, double b, double h) {
length = l;
breadth = b;
height = h;
}
double Volume() {
return length * breadth * height;
}
int compare(Box box) {
return this->Volume() > box.Volume();
}
};
int main(void)
{
Box Box1(3.3, 1.2, 1.5);
Box Box2(8.5, 6.0, 2.0);
if(Box1.compare(Box2)) {
cout << "Box2 is smaller than Box1" <<endl;
}
else {
cout << "Box2 is equal to or larger than Box1" <<endl;
}
return 0;
}
هاي من الملزمة بس اتوقع يجيبها لأن ما طبقناها
👍6
شيئية OOP
Photo
السؤال الأول /
1- instance
2- memory
3- name
4- member
5- this ->
6- early
7- virtual , implementation
☆●☆
السؤال الثاني /
☆●☆
السؤال الثالث /
1- instance
2- memory
3- name
4- member
5- this ->
6- early
7- virtual , implementation
☆●☆
السؤال الثاني /
#include<iostream>
using namespace std;
class Cars {
private:
string brandN;
int maxspeed, fuelC, safetyR;
public:
Cars(string b,int m,int f,int s):brandN(b),maxspeed(m),fuelC(f),safetyR(s){}
bool operator>(const Cars& other) const {
int pointA=0, pointB=0;
if (maxspeed>other.maxspeed) {
pointA++;
} else {
pointB++;
}
if (fuelC<other.fuelC) {
pointA++;
} else {
pointB++;
}
if (safetyR>other.safetyR) {
pointA++;
} else {
pointB++;
}
return pointA > pointB;
}
};
int main() {
Cars BMW("BMW",300,5,10);
Cars KIA("KIA",200,4,5);
if(BMW > KIA) {
cout <<"BMW has a higher assessment"<< endl;
}else{
cout <<"KIA has a higher assessment"<< endl;
}
return 0;
}
☆●☆
السؤال الثالث /
#include<iostream>
using namespace std;
class customer
{
protected:
string name;
int phonenumber;
int credit;
public:
customer(string n,int ph,int c):name(n),phonenumber(ph),credit(c){}
virtual void call() {
cout << " virtual calling " << endl;
};
};
class prepaid : public customer
{
public:
prepaid(string n,int ph,int c):customer(n,ph,c){}
void call() {
cout<<"prepaid make call"<<endl;
}
};
class postpaid : public customer
{
public:
postpaid(string n,int ph,int c):customer(n,ph,c){}
void call()
{
cout<<"postpaid make call"<<endl;
}
};
int main()
{
prepaid call1("memo",3579,300);
postpaid call2("oeom",2468,600);
customer* ptr=&call1;
ptr->call();
ptr=&call2;
ptr->call();
}
👍3❤2
هندسة حاسبات
Photo
حل السؤال
#include <iostream>
using namespace std;
class Bank {
public:
double balance;
void deposit(double amount) {
if (amount > 0) {
balance += amount;
}
else {
throw "can't deposit a negtive value";
}
}
void withDrawing(double amount) {
if (balance >= amount) {
balance -= amount;
} else {
throw "can't withDrawing more money than your balance";
}
}
void display() {
cout << "your Balance: " << balance << endl;
}
};
int main() {
Bank s1 = {350};
try {
s1.deposit(-5);
} catch (const char* msg) {
cerr << "Error: " << msg << endl;
}
try {
s1.withDrawing(400);
} catch (const char* msg) {
cerr << "Error: " << msg << endl;
}
s1.display();
return 0;
}
👍6❤3
الدكتور كال السؤال مضمون 100% يجيبه بالفاينل
ف هذا سؤال من اسئلة الفاينل
ادرسوه جيداً💀
هو صح كال راح اجيبه ما ينحل
بس نحاول و الله كريم
ف هذا سؤال من اسئلة الفاينل
ادرسوه جيداً💀
هو صح كال راح اجيبه ما ينحل
بس نحاول و الله كريم
🗿7🤣4👍1🔥1
شيئية OOP
#include <iostream> using namespace std; class Box { private: double length; double breadth; double height; public: Box(double l, double b, double h) { length = l; breadth = b; height = h; } double Volume() { return length…
مقارنة اكبر اصغر ( نفس سؤال المد تقريباً بس هذا من الملزمة )
شيئية OOP
كوز اليوم بتاريخ : 2024/4/29
خل اسوي نفس الي يدورون اتنشن
وصلوني 200 لايك و اجيبلكم الحل
وصلوني 200 لايك و اجيبلكم الحل
👍41🤣4👎3🤡3🗿3💊2😈1