عندي اسايمنت بليز ساعدوني
Consider the following class definition:
class Section{ private :
int Sec; //section number.
int count; //number of the students in the section. long *IDs; //IDs of students in the section.
int maxSize // Variable to store the maximum size of ----------------IDs ( students) in the section
public:
Section (const Section & another); Section (int, int ,int);
void addlD(long);
int getCount ( ) ;
void print( ) const;
~Section ( ) ;}
1. Write the definition of class Section (above class) in a header file called “section.h”.
2. Complete the above class by writing the definitions of all member functions in another file (impClass.cpp) and include the header file “section.h”.
a. The Constructor function Section (int, int int) ; initializes the data member Sec , count and maxsize and allocates dynamically one dimensional array pointed by IDs.
b. The Constructor function Section (const Section & another); should copy the content object another to the current object. (copy constructor).
c. The Function addID should add an ID at the end of the array.
d. The function getCount should return the number of students in the section.
e. The function print should prints all students IDs in the section.
f. A Destructor function to destroy all dynamically allocated memory
حليت بس يطلع لي ايرورز
class Section{ private :
int Sec; //section number.
int count; //number of the students in the section.
long *IDs; //IDs of students in the section.
int maxSize // Variable to store the maximum size of ----------------IDs ( students) in the section
public:
Section (const Section & another);
Section (int, int ,int);
void addlD(long);
int getCount ( ) ;
void print( ) const;
~Section ( ) ;
}
#include<iostream>
#include"section.h"
using namespace std;
Section (ints,intc,intms){
Sec=s;
count=c;
maxSize=ms;
IDs=newlong[maxSize];
}
Section (const Section & another){
ms=another.ms;
IDs=newlong[maxSize];
for(inti=0;i<ms;i++)
IDs=another.IDs;
}
void addlD(long){
for(int i=maxSize;i>0;i--)
IDs=IDs[i-1];
maxsize++;
}
int getCount ( ){
return count;
}
void print( ) const{
for(int i=0;i<maxsize;i++)
cout<<IDs<<" "<<endl;
}
~Section ( ){
delete[]IDs;
IDs=NULL;}
#include<iostream>
#include"section.h"
using namespace std;
int main()
{
Section a;
a.Section(const Section & another s1);
a.Section(int s,int c ,int ms);
a.addlD(long id);
a.getCount( );
a.print( )const
system("pause");
return 0;
}
هاي طريقة حلي بس ممكن اتوضحون شنو الغلط فيه
او مشكورين
ناطرة ردودكم