Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

User defined class in std::map

Avatar of anAppBuilder
anAppBuilderFlag for United States of America asked on
6 Comments1 Solution611 ViewsLast Modified:
I have some code where I want to use a user defined class (MyDataSet) in a std::map<int,MyDataSet>.  Do I need to do something to make my class usable in a map?  I'm getting this error
C:/MinGW/x86_64-w64-mingw32/include/c++/tuple:1088:70: error: no matching function for call to 'MyDataSet::MyDataSet()'
Here's the code (as a simplified example):
#include <map>
#include <string>
using namespace std;

class MyDataSet {
    int sessionid;
    string name;
    //Will add other instance variables
    MyDataSet(int, string);

MyDataSet::MyDataSet(int id, string n) {
    	sessionid = id;
	name = n;

int main () {
	MyDataSet myData{1, "two"};
	map<int,MyDataSet> myMap;
	myMap[42] = myData;
Avatar of phoffric
phoffricSoftware Engineering and Matlab Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers