Solved

# C++ Sets and Their Types

Posted on 2007-09-28

I am new to C++, and I am writing a breath first search. I would like to use a set to prevent from adding elements to a data structure that are already contained in that data structure. Thus I know a set is what I want. But besides that I understand sets in C++ yet.

I am having trouble figuring out what types a set can take on. Assume set is included as well as Vertex.h...

std::set<int> mySet;

mySet.insert(10);

// This works!

std::set<Vertex> mySet;

Vertex v;

mySet.insert(v);

// This Doesn't Work!

Can sets only take on primitive data types. Can you make a set hold an object type other than primitive objects?