mercredi 4 octobre 2017

C++ template working in class

Here is my assignment for C++ course. Certainly I will finish it by myself. But there is a place I really have no ideas about. Hope someone can explain that to me. Thanks in advance.

The requirement of this assignment is like this:

We need to use template to create a customized class named Set to realize the functionality of union (using operator +) and intersection (using >operator *). For example,{4,2,3}+{9,4,8,2} will be {8,3,9,2,4} and {3,2,4}*{8,4,9,2} will be {4,2}

Here is the skeleton of the xxxx.h file:

xxxx.h file

See the picture above and pay more attention to the highlighted part. At the lower part, there is a red rectangle and the content is const EType &d = EType(). I know EType is the type that I have declared in the template. But what is EType()? It's a function?

There is no other things related with EType() (i.e. some implementations for that function maybe) in the rest part of the requirement. Actually, the left part is xxxx.cpp file and a result when executing that code. I also post the them here if it would be helpful.

xxxx.cpp and the result

Aucun commentaire:

Enregistrer un commentaire