السلام عليكم ورحمة الله وبركاته،،
تحية طيبة وبعد ،،
ما احتاجه هو برنامج على لغة سي ++ يستخدم الكائنات (Object) مهما كان طبيعة البرنامج، او على لغة Java.
ارجو توضيح البرنامج حتى اتمكن من شرحه امام المحاضر.
مع الشكر لكم
السلام عليكم ورحمة الله وبركاته،،
تحية طيبة وبعد ،،
ما احتاجه هو برنامج على لغة سي ++ يستخدم الكائنات (Object) مهما كان طبيعة البرنامج، او على لغة Java.
ارجو توضيح البرنامج حتى اتمكن من شرحه امام المحاضر.
مع الشكر لكم
ابحث حتلاقي كنيييييييير
ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust
//Note: I wrote this program & I didn't compile it
//Cuz i'm not at home right now
#include <iostream>
using namespace std;
//Class definition
Class John
{
public:
//Methods
void Talk();
void GetPower(int power);
private:
//Data
int m_Power();
};
//Class implementation
void John::Talk()
{
cout << "Hi, i'm John, and I'm C++ object!" << endl;
}
void John::GetPower(int power)
{
m_Power = power;
if (power <= 0)
power = 0;
cout << "My power is: " << m_Power << endl;
}
int main()
{
cout << "Creating object..." << endl;
John myJohn; //Creating johny object derived from John class
myJohn.Talk(); //Calling Talk(); function
myJohn.GetPower(); //Calling GetPower(); function
return 0;
}IDE : Microsoft Visual Studio 2005 Pro
الكود الاول فيه جم خطأ :D
هذا مافيه خطا بعد ما رديت البيت :) :
#include <iostream>
#include <conio.h>
using namespace std;
//Class definition
class John
{
public:
//Methods
void Talk();
void GetPower(int power);
private:
//Data
int m_Power();
};
//Class implementation
void John::Talk()
{
cout << "Hi, i'm John, and I'm C++ object!" << endl;
}
void John::GetPower(int power)
{
int m_Power = power;
if (power <= 0)
power = 0;
cout << "My power is: " << m_Power << endl;
}
int main()
{
cout << "Creating object..." << endl;
John myJohn; //Creating johny object derived from John class
myJohn.Talk(); //Calling Talk(); function
myJohn.GetPower(5); //Calling GetPower(); function
getch();
return 0;
}IDE : Microsoft Visual Studio 2005 Pro
هذا الموضوع مغلق.