الفاينل لأي جبتر ؟؟

هاااي
شسويتو في الميدتيرم شلون الدرجات


الدرجات كانت اقل مما توقعنا بواجد
بس الحمدلله على كل حال ، احسن من غيرنا


حاولت احلة بس ما عرفت في احد يقدر يساعدني فية
[*=center]Consider the following definition of the Struct Phone:
struct Phone {
string name;
int area;
int number;
};
Write a program that do the following:
[*=center]Write a void value-returning function called DeepCopy that takes two pointers of type Phone and copy the location pointed by the second into the location pointed by the first one.
[*=center]Write a Boolean value-returning function called DeepCompare that takes two pointers of type Phone and returns true if the structs that they point have identical values in their corresponding fields.
[*=center]Write a Boolean value-returning function called ShallowCompare that takes two pointers of type Phone and returns true if they point to the same struct and false otherwise.
[*=center]In the main function:
[*=center]Declare two pointers Pp1 and Pp2 of type Phone.
[*=center]Create two dynamic locations that will be pointed by Pp1 and Pp2 .
[*=center]Store “ Ahmed, 973, and 17454568” respectively into the new location pointed by Pp1.
[*=center]Copy the values of location pointed by Pp1 into the new location pointed by Pp2(using?).
[*=center]Check if locations pointed by Pp1 and Pp2 have same values (using?)
[*=center]Check if Pp1 and Pp2 are pointing to the same location (using?)
[*=center]Delete the dynamic locations pointed by Pp1 and Pp2.
[*=center]Declare a pointer variable Phonebook of type Phone.
[*=center]Create dynamic array of size=10 that will be pointed by Phonebook.
[*=center]Store “Amina, 973, and 17435833” respectively into element 2 of the dynamic array Phonebook.
[*=center]Delete the dynamic array Phonebook.ياليت احد يساعدني
ضروري
حاول تساعدني فية ,,
دكتور يشرح شيء
والاسايمنتات شيء ثاني

حاولت احلة بس ما عرفت في احد يقدر يساعدني فية
[*=center]Consider the following definition of the Struct Phone:
struct Phone {
string name;
int area;
int number;
};
Write a program that do the following:
[*=center]Write a void value-returning function called DeepCopy that takes two pointers of type Phone and copy the location pointed by the second into the location pointed by the first one.
[*=center]Write a Boolean value-returning function called DeepCompare that takes two pointers of type Phone and returns true if the structs that they point have identical values in their corresponding fields.
[*=center]Write a Boolean value-returning function called ShallowCompare that takes two pointers of type Phone and returns true if they point to the same struct and false otherwise.
[*=center]In the main function:
[*=center]Declare two pointers Pp1 and Pp2 of type Phone.
[*=center]Create two dynamic locations that will be pointed by Pp1 and Pp2 .
[*=center]Store “ Ahmed, 973, and 17454568” respectively into the new location pointed by Pp1.
[*=center]Copy the values of location pointed by Pp1 into the new location pointed by Pp2(using?).
[*=center]Check if locations pointed by Pp1 and Pp2 have same values (using?)
[*=center]Check if Pp1 and Pp2 are pointing to the same location (using?)
[*=center]Delete the dynamic locations pointed by Pp1 and Pp2.
[*=center]Declare a pointer variable Phonebook of type Phone.
[*=center]Create dynamic array of size=10 that will be pointed by Phonebook.
[*=center]Store “Amina, 973, and 17435833” respectively into element 2 of the dynamic array Phonebook.
[*=center]Delete the dynamic array Phonebook.ياليت احد يساعدني
ضروري

#include<iostream>
Using namespace std;
struct phone {
string name;
int area;
int number;
};
void DeepCopy (phone *x, phone *y){
x.area=y.area;
}
bool DeepCompare(phone *p1, phone *p2){
return( p1.name==p2.name && p1.area==p2.area && p1.number==p2.number);
}
حاولت احلة بس ما عرفت في احد يقدر يساعدني فية
[*=center]Consider the following definition of the Struct Phone:
struct Phone {
string name;
int area;
int number;
};
Write a program that do the following:
[*=center]Write a void value-returning function called DeepCopy that takes two pointers of type Phone and copy the location pointed by the second into the location pointed by the first one.
[*=center]Write a Boolean value-returning function called DeepCompare that takes two pointers of type Phone and returns true if the structs that they point have identical values in their corresponding fields.
[*=center]Write a Boolean value-returning function called ShallowCompare that takes two pointers of type Phone and returns true if they point to the same struct and false otherwise.
[*=center]In the main function:
[*=center]Declare two pointers Pp1 and Pp2 of type Phone.
[*=center]Create two dynamic locations that will be pointed by Pp1 and Pp2 .
[*=center]Store “ Ahmed, 973, and 17454568” respectively into the new location pointed by Pp1.
[*=center]Copy the values of location pointed by Pp1 into the new location pointed by Pp2(using?).
[*=center]Check if locations pointed by Pp1 and Pp2 have same values (using?)
[*=center]Check if Pp1 and Pp2 are pointing to the same location (using?)
[*=center]Delete the dynamic locations pointed by Pp1 and Pp2.
[*=center]Declare a pointer variable Phonebook of type Phone.
[*=center]Create dynamic array of size=10 that will be pointed by Phonebook.
[*=center]Store “Amina, 973, and 17435833” respectively into element 2 of the dynamic array Phonebook.
[*=center]Delete the dynamic array Phonebook.ياليت احد يساعدني
ضروري

#include<iostream>
Using namespace std;
struct phone {
string name;
int area;
int number;
};
void DeepCopy (phone *x, phone *y){
x.area=y.area;
}
bool DeepCompare(phone *p1, phone *p2){
return( p1.name==p2.name && p1.area==p2.area && p1.number==p2.number);
}
bool ShallowCompare(phone *p1, phone *p2){
return( p1.name==p2.name && p1.area==p2.area && p1.number==p2.number);
}
void main(){
phone *Pp1;
phone *Pp2;
Pp1=new phone;
Pp2=new phone;
Pp1->name="ahmed";
Pp1->area=973;
Pp1->number= 17454568;
DeepCopy (*Pp1, *Pp2);
DeepCompare(*Pp1,*Pp2);
ShallowCompare(*Pp1, *Pp2);
delete Pp1;
delete Pp2;
phone *phonebook;
phonebook=new phone[10];
for(int i=0;i<10;i++)
{ if(i==2)
{ Phonbook[i]->name="amina";
Phonebook[i]->area=973;
Phonebook[i]->number= 17435833;
}
}
delete []phonebook;
}
Write a void value-returning function called DeepCopy that takes two pointers of type Phone and copy the location pointed by the second into the location pointed by the first one.
Write a Boolean value-returning function called DeepCompare that takes two pointers of type Phone and returns true if the structs that they point have identical values in their corresponding fields.
Write a Boolean value-returning function called ShallowCompare that takes two pointers of type Phone and returns true if they point to the same struct and false otherwise.
فنكشن
deepCopy بتسوي كوبي الى اللوكيشن اللي ياشر عليه البونتر نفسه
ااذا سوينا جدي p = q هذا نسميه shallow
والديب بيكون جدي p = new phone; وعقب اسوي كوبي الى الفيمه اللي داخل q بتصير جدي *p = *q;
فنكشن الثانيه deepCompare تجيك القيم اللي داخل البونتر اذا متشابهين او لا p->name == q->name ومثلا الشي الى الباقي
الفنكشن الثالثه تجيك البونتر نفسه اذا كان ياشر على نفس المكان او لا if(p== q ) بس
عندي اسايمنت الحمدلله سويته والبرنامج مايقول ان في خلل بالكود .. بس لما اسوي ديبق !!
يعطيني هالايرور ..
Invalid allocation size: 4294967295 bytes
بالنت مكتوب عن سالفة -1 مادري ويش وصراحة مافهمت !!
احد يعرف ويش المشكلة .. ؟


#include<iostream>
#include<string>
using namespace std;
class shoppingList {
private:
string *list ;
int maxSize ;
int numItems ;
public:
shoppingList ( ) ;
~shoppingList ( ) ;
shoppingList ( const shoppingList & ) ;
void printList () ;
void addNewItem (string) ;
};
shoppingList::shoppingList ( )
{
maxSize=10;
list = new string [maxSize];
numItems = 0 ;
}
shoppingList::~shoppingList ()
{
cout << "All data delete " ;
delete [] list ;
list = 0 ;
}
shoppingList::shoppingList ( const shoppingList & A )
{
numItems= A.numItems ;
string * p ;
p = new string [maxSize] ;
for ( int i = 0 ; i< A.numItems ; i ++ )
list[i] = A.list[i] ;
}
void shoppingList::addNewItem (string y)
{
if ( maxSize > numItems )
{
list[numItems] = y ;
numItems ++ ;
}
}
void shoppingList::printList ()
{
cout << " all the information about shoppingList : " << endl ;
cout << " maxSize : " << maxSize << endl ;
cout << " numItems : " << numItems << endl ;
cout << " information of Array : " << endl ;
for ( int i = 0 ; i < numItems ; i ++ )
cout << list[i] << endl;
}
int main()
{
shoppingList firstList;
firstList.addNewItem("Rice") ;
firstList.addNewItem("Sugar") ;
shoppingList secondList (firstList) ;
firstList.printList () ;
secondList.printList () ;
return 0 ;
}
اكوهااا
كود:#include<iostream> #include<string> using namespace std; class shoppingList { private: string *list ; int maxSize ; int numItems ; public: shoppingList ( ) ; ~shoppingList ( ) ; shoppingList ( const shoppingList & ) ; void printList () ; void addNewItem (string) ; }; shoppingList::shoppingList ( ) { maxSize=10; list = new string [maxSize]; numItems = 0 ; } shoppingList::~shoppingList () { cout << "All data delete " ; delete [] list ; list = NULL ; } shoppingList::shoppingList ( const shoppingList & A ) { numItems= A.numItems ; string * p ; p = new string [maxSize] ; for ( int i = 0 ; i< A.numItems ; i ++ ) list[i] = A.list[i] ; } void shoppingList::addNewItem (string y) { if ( maxSize > numItems ) { list[numItems] = y ; numItems ++ ; } } void shoppingList::printList () { cout << " all the information about shoppingList : " << endl ; cout << " maxSize : " << maxSize << endl ; cout << " numItems : " << numItems << endl ; cout << " information of Array : " << endl ; for ( int i = 0 ; i < numItems ; i ++ ) cout << list[i] << endl; } int main() { shoppingList firstList; firstList.addNewItem("Rice") ; firstList.addNewItem("Sugar") ; shoppingList secondList (firstList) ; firstList.printList () ; secondList.printList () ; return 0 ; }
[COLOR=#000000][B][FONT=tahoma][SIZE=2]
shoppingList::shoppingList ( const shoppingList & A ) [/SIZE][/FONT][/B][/COLOR]
نفس الي سويناه باللاب .. واي مايشتغل ..
بس كأن انتينا مسويه اشياء زياده على الي سويته في هالفنكشن .. مادري هم صح او غلط .. لأن يعتمد على اسلوبش بالحل ..
كود:[COLOR=#000000][FONT=tahoma][SIZE=2] shoppingList::shoppingList ( const shoppingList & A ) [/SIZE][/FONT][/COLOR]
