Hi!!!
How Are you
I bring a new program which I have solve it ; but there are 7 error without explain
please I hope that I have any body to help me and I will be happy
thhhhhanks alot :)

This is the question

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
  3. write the main program that tests the above class in another file (your-group-number.cpp) and include the-header file "section.h".

Main should include the following:
1) Create an instance ( object) named Sec1 of type Section with sec=1, count=0 and maxSize =20.
2) Write a statement to add the id 111 to Sec1.
3) Write a statement to add the id 222 to Sec1.
4) Write a statement to print the details of Sec1.
5) Create an instance ( object) named Sec2 of type Section with the same IDs of Sec1 using the copy constructor.
6) Write a statement add the id 333 to Sec1.
7) Write a statement to print the details of Sec2.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

#include <iostream>
using namespace std;

class Section
{

private :
     int Sec;
     int  count;
     long *IDs;
    int maxSize;

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;

int main()
{
Section sec1(3,50,30);
long IDs;

cout<<"enter the number of the students in the section";
sec1.getCount();
 
cout<<"enter the Ids of the section";
sec1.addlD(IDs);
sec1.print();
cout<<endl;


Section sec2 (sec1);
cout<<"after calling the function";
cout<<"sec2";
sec2.print();


return 0;

}



#include<iostream>
#include"section.h"

using namespace std;

Section::Section (int sect, int max ,int coun)
{

    Sec=sect;
    maxSize=max;
    count=coun;

IDs=new long [max];

}

Section::Section (const Section & another)
{
	maxSize=another.maxSize;
	count=another.count;

    IDs=new long [maxSize];
	for ( int i=0;i<count;i++)
       IDs[i]=another.IDs[i];

}

void Section::addlD(long)
{
	for (int j=0; j<maxSize;j++)
		cin>>IDs [j];
     IDs++;
}

int Section:: getCount ( )
{
	return count;

}

void Section:: print( ) const
{
for (int j=0; j<maxSize;j++)
		cout<<IDs[j]<<"";
    

}

Section::~Section ( ) 
{
	delete [] IDs;
}

What errors are you getting? The code compiles for Edward with only a warning about IDs being used before initialization.

This article has been dead for over six months. Start a new discussion instead.