Home > Back-end >  Seek help from bosses, c an experiment
Seek help from bosses, c an experiment

Time:09-27

 
//Project01 CPP: Defines the entry point for the console application.
//

# include "stdafx. H"
# include & lt; iostream>
# include & lt; Vector>
# include & lt; Time. H>
# include & lt; Algorithm>
using namespace std;
# define IDMAX 1000
/*
The student class
Requirements:
1, student ID, ID for unsigned integer, value range is 1 ~ IDMAX
2, to complete the class three constructor, the default constructor can be randomly generated an ID
3, overloading student class assignment operator
4, overloading the student class==operator, requirements: when the object ID of the phase at the same time, two students think that the two objects are equal
*/
The class Student
{

Private:
Unsigned int m_uiId;
Public:
Student();

Student (const Student & amp; Student);
Student & amp; Operator=(const Student & amp; Student);
Boolean operator==(const Student & amp; Student);
};

/*
Student collection class
Requirements:
1, the elements in the collection for the Student object, using the vector storage;
2, realize the default constructor, copy constructor
3, the overloaded assignment operator and the==operator
4, realize to the collection (Insert) to Insert and delete (Remove) operation
5, realizes the collection and (Union), delivery (intersects), Difference (Difference), fill (Complement) and symmetric Difference (SymDifference), which Complement arithmetic to {1... IDMAX} for complete
6, to achieve an empty set judgment (IsEmpty)
7, realizes the collection of empty operation (the Clear
)
8, the realization of print collection of all the students operation of student number (the Output)
*/
The class StudentSet
{
Private:
vector M_vecData;
Public:
StudentSet ();
StudentSet (const StudentSet & amp; Studentset);
StudentSet & amp; Operator=(const StudentSet & amp; Studentset);
Boolean operator==(const StudentSet & amp; Studentset);
Bool Insert (const Student Student);
Bool Remove (const int id);
StudentSet Union (const StudentSet & amp; Studentset);
StudentSet intersects (const StudentSet & amp; Studentset);
StudentSet Difference (const StudentSet & amp; Studentset);
StudentSet Complement ();
StudentSet SymDifference (const StudentSet & amp; Studentset);
Boolean IsEmpty ();
Void the Clear ();
Void the Output ();
};


Int main ()
{
Srand ((unsigned int) time (NULL));
StudentSet characters, set2 set3;
Characters. The Clear ();
Set2. The Clear ();
Set3. The Clear ();
For (unsigned int I=0; i <50; I++)
{
Student tmpstudent (I);
Characters. The Insert (tmpstudent);
}

Characters. The Output ();

Student tmpstudent (10);
cout
For (unsigned int I=30; i <70; I++)
{
Student tmpstudent (I);
Set2. Insert (tmpstudent);
}

Set2. The Output ();

Set3=characters. The Union (set2);
Set3. The Output ();

Set3=characters. Intersects (set2);
Set3. The Output ();

Set3=characters. The Difference (set2);
Set3. The Output ();

Set3.Com plement ();
Set3. The Output ();

Set3=characters. SymDifference (set2);
Set3. The Output ();

system("pause");
return 0;
}
  • Related