الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

هام وعاجل ... إكمال برنامج بلغة سي بلس بلس

بدأه رسل2008 في 4 ديسمبر 2008 · 8 رد · 922 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

The project ..of 11 steps

The IT college

The main class is named person , Two classes inheritant from the main class :Student ,Employee

The members of the main class are :Identifier Id ,name ,Sex

The Member of the Student :student number , the Specialization of the student

The member of the class employee : employee number ,the work he do

Using the overload Function in output and input .

Using the writeload Function in the print Function.

Insert at lest 10 student and 10 employees

Print the list of the employees as a table with all own data.

Print the list of the Students as a table with all own data.

The proportion of male to female in the employee

After finish built a destructor function to destruct all the objects in the class.

انا وضعت الجزء الذي استطعت أن أحله في ملف .. وتستطيعون الاطلاع عليه من خلال الرابط التالي

http://www.gulfup.com/dldlWz41103.rar.html

أرجو منكم مساعدتي في اكمال البرنامج

البرنامج مهم وضروري بالنسبة لي

وبارك الله فيكـم ووفقكم لما يحبه ويرضاه

وشكرا جزيلا لكم

تم تعديل هذه المشاركة بواسطة رسل2008 في 4 ديسمبر 2008 في 01:04

#2
#include <string.h>
#include <iostream.h>
class person
{
public:
person(){}
person (int id,char*name,char*sex)
{
	this->id=id;
	strcpy(this->name,name);
	strcpy(this->sex,sex);
}

int id;
char sex[10];
char name[20];

};

class student: public person
{
public:
student(){}
student(int number,char*name,char*sex,char*spec):person(number,name,sex)
{
	this->number=number;
	strcpy(this->spec,spec);
}

int number;
char spec[20];

};

class employee: public person
{
public:
employee(){}
employee(int number,char*name,char*sex,char *working):person(id,name,sex)
{
	this->number=number;
	strcpy(this->working,working);
}

int number;
char * working;

};


int main()
{
	employee *emp;
	student *stu;

	emp=new employee[10];
	stu=new student[10];

	cout<<"students:"<<endl;
	for(int i=0;i<10;++i)
	{
		stu.id=i;
		cout<<"name: ";
		cin>> stu.name;
		cout<<"sex: ";
		cin>> stu.sex;
		/* continue here

		*/
	}
	cout<<"employees:"<<endl;
	for(i=0;i<10;++i)
	{
		emp.id=i;
		cout<<"name: ";
		cin>> emp.name;
		cout<<"sex: ";
		cin>> emp.sex;

		/*continue here

		*/
	}

	cout<<"students:"<<endl;
	cout<<"id\tname\tsex"<<endl; //continue here

	for (i =0; i<10;++i)
	{
		cout<<stu.id<<"\t"<<stu.name<<"\t"<<stu.sex<<endl;// continue here
	}

	cout<<"employees:"<<endl;
	cout<<"id\tname\tsex"<<endl; //continue here

	for (i =0; i<10;++i)
	{
		cout<<emp.id<<"\t"<<emp.name<<"\t"<<emp.sex<<endl;// continue here
	}

	return 0;
}

دولة الخلافة الاسلامية في المخاض الاخير وميلادها قريب

حزب التحرير : التزم الطريق الصحيح الشرعي الوحيد لاعادة دولة الخلافة الاسلامية .

الامة الاسلامية متعطشة لقيادة مخلصة لتذوق حلاوة النصر ولن يكون ذلك الا بعودة الخلافة الاسلامية

الامة الاسلامية تحتاج لاحداث تسحقها سحقا وتمعسها معسا لتفكر تفكيرا جماعيا بالتغير لان وحدة المشاعر لوحدها لاتكفي وهذة الاحداث كلها خير

#3

أولاً جزاك الله خير الجزاء على مجهودك

هل هذا البرنامج كاملاً ؟؟ أم مضاف إلى ما يوجد بالملف الموجود في الرابط؟؟؟

وأكرر ألف شكر إلك أخي mandareka

تقبل فائق التقدير والاحترام

#4

لا ينقصه إلا إكمال الأسطر المكتوب عليها

//continue here//

يعمل على Turbo C++ 3

تم تعديل هذه المشاركة بواسطة mandareka في 4 ديسمبر 2008 في 12:25

دولة الخلافة الاسلامية في المخاض الاخير وميلادها قريب

حزب التحرير : التزم الطريق الصحيح الشرعي الوحيد لاعادة دولة الخلافة الاسلامية .

الامة الاسلامية متعطشة لقيادة مخلصة لتذوق حلاوة النصر ولن يكون ذلك الا بعودة الخلافة الاسلامية

الامة الاسلامية تحتاج لاحداث تسحقها سحقا وتمعسها معسا لتفكر تفكيرا جماعيا بالتغير لان وحدة المشاعر لوحدها لاتكفي وهذة الاحداث كلها خير

#5
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class person {
  6. public:
  7. person(int,char,string);
  8. int id();
  9. char sex();
  10. string name();
  11. private:
  12. int person_id;
  13. char person_sex;
  14. string person_name;
  15. };
  16.  
  17. class student: public person {
  18. public:
  19. student (int,char);
  20. int number();
  21. char specialization;
  22. private:
  23. int student_number;
  24. char student_specialization;
  25. };
  26.  
  27. class employee: public person {
  28. public:
  29. employee (int,char);
  30. int number ();
  31. char working ();
  32. private:
  33. int employee_number;
  34. char employee_working;
  35. };
  36.  
  37. person::person(int a, char b, string c) {
  38. person_id=a;
  39. person_sex=b;
  40. person_name=c;
  41. }
  42.  
  43. int person::id() {
  44. return (person_id);
  45. }
  46.  
  47. int person::sex() {
  48. return (person_sex);
  49. }
  50.  
  51. string person::name() {
  52. return (person_name);
  53. }
  54.  
  55. student::student(int a, char b ) {
  56. student_number=a;
  57. student_specialization=b;
  58. }
  59.  
  60. int student::number() {
  61. return (student_number);
  62. }
  63.  
  64. char student::specialization() {
  65. return (student_specialization);
  66. }
  67.  
  68. employee::employee(int a, char b ) {
  69. employee_number=a;
  70. employee_working=b;
  71. }
  72.  
  73. int employee::number() {
  74. return (employee_number);
  75. }
  76.  
  77. int employee::working() {
  78. return (employee_working);
  79. }
  80.  
  81. int main()
  82. {
  83. employee *emp;
  84. student *stu;
  85.  
  86. emp=new employee[10];
  87. stu=new student[10];
  88.  
  89. cout<<"students:"<<endl;
  90. for(int i=0;i<10;++i)
  91. {
  92.  
  93. stu[i].id=i;
  94. cout<<"name: ";
  95. cin>> stu[i].name;
  96. cout<<"sex: ";
  97. cin>> stu[i].sex;
  98. string Student::getGender() const;
  99. {
  100. if( Gender == Male )
  101. cout<< "Male"<<endl;
  102. else if( Gender == Female )
  103. cout<< "Female"<<endl;
  104. else
  105. cout<< "Unspecified"<<endl;
  106. }
  107.  
  108. cout<<"employees:"<<endl;
  109. for(i=0;i<10;++i)
  110. {
  111. emp[i].id=i;
  112. cout<<"name: ";
  113. cin>> emp[i].name;
  114. cout<<"sex: ";
  115. cin>> emp[i].sex;
  116. string Employee::getGender() const;
  117.  
  118. if( Gender == Male )
  119. cout<< "Male"<<endl;
  120. else if( Gender == Female )
  121. cout<< "Female"<<endl;
  122. else
  123. cout<< "Unspecified"<<endl;
  124. }
  125.  
  126. cout<<"students:"<<endl;
  127. cout<<"idtnametsex"<<endl;
  128. cin>> stu[i].name;
  129. cin>> stu[i].sex;
  130. for (i =0; i<10;++i)
  131. {
  132. cout<<stu[i].id<<"t"<<stu[i].name<<"t"<<stu[i].sex<<endl;
  133. cout<<"-------------------------------------------------------------------------"<<endl;
  134.  
  135. student::~students()
  136. cout::std<<"Destructing students<<stu.id<<"t"<<stu.name<<"t"<<stu.sex<<endl;
  137. cout<<"-------------------------------------------------------------------------"<<endl
    ;
  138. }
  139. cout<<"employees:"<<endl;
  140. cout<<"idtnametsex"<<endl;
  141. cin>> emp.name;
  142. cin>> emp.sex;
  143. cout<<"-------------------------------------------------------------------------"<<endl;
  144. for (i =0; i<10;++i)
  145. {
  146. cout<<emp.id<<"t"<<emp.name<<"t"<<emp.sex<<endl;
  147.  
  148. cout<<"-------------------------------------------------------------------------"<<endl;
  149. employee::~employee();
  150. cout::std<<"Destructing employee<< emp[i].id<<"t"<<emp[i].name<<"t"<<emp[i].sex<<endl;
  151. }
  152. {
  153. person::~person();
  154. cout::std<<"Destructing person<< per.id<<"t"<<per.name<<"t"<<per.sex<<endl;
  155.  
  156. }
  157. return 0;
  158. }
  159.  

شكــرا لتعاونكم معنــا

تقبلوا احترامي وتقديري

#6

ماشاء الله عليك عمل جميل

وانصح اخي السائل يستفيد منه ومن الروابط اللي التي عملتها انا بالسابق عندما كنت مشرفا على قسم السي++

لكم مني خالص التقدير

*********************

دروس الاكسس

قاعدة بيانات بالسي++

قاعدة بيانات اخرى بالسي++

الفريق العربي للبرمجه

*********************

كان الله في عون العبد مادام العبد في عون اخيه

#7

شكراً لمرورك أستاذ عبدالهادي

*****************

إخواني أريد تقييم للبرنامج؟؟ هل إكماله تم بشكل صحيح أم لا؟؟

******************

ودمتم

#8
  1.  
  2. #define male 'm'
  3. #define female 'f'
  4.  
  5. #include <iostream>
  6. #include <cstdlib>
  7. #include <ctime>
  8. #include <string>
  9. using namespace std;
  10.  
  11. class person
  12. {
  13. public:
  14. person(int,char,string);
  15. person();
  16. int id();
  17. char sex();
  18. string name();
  19. int changename(string);
  20. static int reset_count();
  21. protected:
  22. int person_id;
  23. char person_sex;
  24. string person_name;
  25. };
  26.  
  27. class student: public person
  28. {
  29. public:
  30. student (string,char);
  31. student (string,char,char);
  32. int number();
  33. char specialization();
  34. protected:
  35. int student_number;
  36. char student_specialization;
  37. };
  38.  
  39. class employee: public person
  40. {
  41. public:
  42. employee (int,char);
  43. employee (string,char,char);
  44. int number ();
  45. char working ();
  46. protected:
  47. int employee_number;
  48. char employee_working;
  49. };
  50.  
  51. int person::count;
  52.  
  53. int person::reset_count() {
  54. person::count=0;
  55. return (person::count);
  56. }
  57.  
  58. person::person(int a, char b, string c)
  59. {
  60. person_id=person::count;
  61. person::count++;
  62. person_sex=b;
  63. person_name=c;
  64. }
  65.  
  66. person::person()
  67. {
  68. person_id=person::count;
  69. person::count++;
  70. char this_persons_sex;
  71. int random=rand()%2;
  72. if (random==0) this_persons_sex='m';
  73. else this_persons_sex='f';
  74. person_sex=this_persons_sex;
  75. person_name="";
  76. }
  77.  
  78.  
  79. int person::id()
  80. {
  81. return (person_id);
  82. }
  83.  
  84. char person::sex()
  85. {
  86. return (person_sex);
  87. }
  88.  
  89. string person::name()
  90. {
  91. return (person_name);
  92. }
  93.  
  94. int person::changename(string a)
  95. {
  96. person_name=a;
  97. return 0;
  98. }
  99.  
  100.  
  101. student::student(string a, char b )
  102. {
  103. student_number=person_id;
  104. person_name=a;
  105. student_specialization=b;
  106. }
  107.  
  108. student::student(string a, char b, char c )
  109. {
  110. person_name=a;
  111. student_number=person_id;
  112. student_specialization=b;
  113. person_sex=c;
  114. }
  115.  
  116. int student::number()
  117. {
  118. return (student_number);
  119. }
  120.  
  121. char student::specialization()
  122. {
  123. return (student_specialization);
  124. }
  125.  
  126. employee::employee(int a, char b )
  127. {
  128. employee_number=a;
  129. employee_working=b;
  130. }
  131.  
  132. employee::employee(string a, char b, char c )
  133. {
  134. person_name=a;
  135. employee_number=person_id;
  136. person_sex=b;
  137. employee_working=c;
  138. }
  139.  
  140. int employee::number()
  141. {
  142. return (employee_number);
  143. }
  144.  
  145. char employee::working()
  146. {
  147. return (employee_working);
  148. }
  149.  
  150. int main()
  151. {
  152. person::reset_count();
  153. srand(time(NULL));
  154. employee ** emp;
  155. student ** stu;
  156. char tmpsex;
  157. string tmpname;
  158. string junk;
  159. char tmpspec;
  160. emp=new employee*[10];
  161. stu=new student*[10];
  162.  
  163. cout<<"students:"<<endl;
  164. for (int i=0;i<10;i++)
  165. {
  166. cout<<"name: ";
  167. getline(cin,tmpname);
  168. cout<<"specialization: ";
  169. cin >> tmpspec;
  170. cout<<"sex: ";
  171. cin >> tmpsex;
  172. getline(cin,junk); // clear input buffer from junk cin leaves there
  173. stu[i]=new student(tmpname,tmpspec,tmpsex);
  174. }
  175. cout<<"employees:"<<endl;
  176. for (int i=0;i<10;i++)
  177. {
  178. cout<<"name: ";
  179. getline(cin,tmpname);
  180. cout<<"sex: ";
  181. cin>> tmpsex;
  182. cout << "Working?: ";
  183. cin >> tmpspec;
  184. getline(cin,junk);
  185. emp[i]=new employee(tmpname,tmpsex,tmpspec);
  186. }
  187. cout << "Student Data:nidtnametsextspecializationn";
  188. cout<<"-------------------------------------------------------------------------"<<endl;
  189. for (int i =0; i<10;++i)
  190. {
  191. cout<<stu[i]->id()<<"t"<<stu[i]->name()<<"t"<<stu[i]->sex()<<"t"<<stu[i]->specializatio
    n()<<endl;
  192. }
  193. cout<<"-------------------------------------------------------------------------"<<endl;
  194. cout << "nEmployee Data:nidtnametsextworkingn";
  195. cout<<"-------------------------------------------------------------------------"<<endl;
  196. for (int i =0; i<10;++i)
  197. {
  198. cout<<emp[i]->id()<<"t"<<emp[i]->name()<<"t"<<emp[i]->sex()<<"t"<<emp[i]->working()<<en
    dl;
  199. }
  200. cout<<"-------------------------------------------------------------------------"<<endl;
  201. cout<<"nnPress <ENTER> to Exit. ";
  202. cin.get();
  203. return 0;
  204. }
  205.  
  206.  

الآن بقي لي أخر خطوة في البرنامج

After finish built a destructor function to destruct all the objects in the class.

هدم جميع الـ

objects

لو سمحتم كيف أستخدم

delete

في هدم

objects

:happy: وبارك الله فيكم

تم تعديل هذه المشاركة بواسطة رسل2008 في 7 ديسمبر 2008 في 08:52

#9

السلام عليكم ورحمة الله وبركاته

يا جماعة في مجال إنه أحد يكمل البرنامج في اخر فقرة فيه أولا؟؟

أرجو منكم الرد

وشكراً

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…