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

أريد معرفة الخطأ في هذا البرنامج

مغلق
بدأه bebe في 2 مارس 2005 · 2 رد · 442 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمه الله وبركاته رجو مساعدتي في هذا البرنامج فقد قمت بالمحاوله ولكن لاأدري ماهو الخطأ وارجو مساعدتي

في كيفي تخزززين عناصر class في مصفووفه ثم البحث عنها عن طريق search

وجزاكم الله خيرا

--------------------------------------------------------------------------------

a.some of the characteristic of a book are the title ,authors,publishers,Isbn ,price,and year of publication.desien a class booktype the define the book

1-each object of the class booktypr handled the following informaintion title up to four, publisher,isbn,price,number of copice in stock,to keep tack of the number of author add anthor data member

2-include the member functions to perform the various operation on objects of the type booktype for example theat can peroformed on the title are to ahow the title and check whether a title is the same as actual title of the book.

and also we can search of the book with the title

AND THIS A TRY

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

class Student
{
public:
	Student();
	void setAll(string, float, int);
	void getAll(string&, float&, int&);
	void printStudentDetails();
	void computeType();
private:

	float price;
	int ISBN;
	string author;

};

string auth;
float pri;
int i,j;



Student:: Student()
{
	author = ""; // BECAUSE ITS A STRING
	price = 0.0; // BECAUSE ITS A FLOAT
	ISBN = 0; // BECAUSE ITS INTGER
}

void Student:: setAll(string auth, float pri, int i)
{


	cout<<"Please enter the author name" <<endl;
	cin>>auth;
	cout<<"Enter the price" <<endl;
	cin>>pri;
	cout<<"please enter ISBAN" <<endl;
	cin>>i;

author = auth;
price = pri;
ISBN = i;

}

void Student:: getAll(string& auh, float& pri, int& i)
{
	author = auth;
price = pri;
ISBN = i;
}

void Student:: computeType()

{





}

void Student:: printStudentDetails()
{
	getAll(author, pri, i);

	cout<<"the author name is"<<author<<endl;
	cout<<"the book isban"<<i<<endl;
	cout<<"the book price:"<<price<<endl;

computeType();


}

int main ()
{
	Student std1,std2;
int x[3],y[3];


	std1.setAll(auth,pri,i);
	std1.getAll(auth,pri,i);
	std1.printStudentDetails();
    x[1]=std1.author;
	x[2]=std1.ISBN;
	x[3]=std1.price;
	std2.setAll(auth,pri,i);
	std2.getAll(auth,pri,i);
	std2.printStudentDetails();

	y[1]=std2.author;
    y[2]=std2.ISBN;
	y[3]=std2.price;

	return 0;
}

تم تعديل هذه المشاركة بواسطة bebe في 2 مارس 2005 في 19:35

#2
{
Student std1,std2;
int x[3],y[3];-------------------------------------(1)


std1.setAll(auth,pri,i);
std1.getAll(auth,pri,i);
std1.printStudentDetails();
   x[1]=std1.author;
x[2]=std1.ISBN;
x[3]=std1.price;
std2.setAll(auth,pri,i);
std2.getAll(auth,pri,i);
std2.printStudentDetails();

y[1]=std2.author;
   y[2]=std2.ISBN;
y[3]=std2.price;

return 0;
}

الخطأ في السطر واحد أنت الآن تبي تخزن في المصفوفة object من النوع student ففي تعريف المصفوفة تعرفها على أنها من النوع student

student x[3],y[3];

أما عملية البحث فتقوم بإرسال الـobject المراد البحث عنه للدالة search وتبحث عنه بحث عادي بالـ For loop

#3

thank u :)

هذا الموضوع مغلق.

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

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

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

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

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