Solved

Inserting into a set

Posted on 2002-06-19
5
221 Views
Last Modified: 2010-04-01
The following insert call produces a link error and I have no clue why.  Any suggestions?

extern set<My_Data> My_DataSet;

...

bool My_Data::AddRecord( char * trackingNumber, char * scanInfo )
{
     My_DataSet.insert(My_Data( trackingNumber, scanInfo ));//the link error is here
...
     return true;
}
0
Comment
Question by:mudface061200
5 Comments
 
LVL 4

Expert Comment

by:Chase707
ID: 7093984
What is the exact linker error that you are getting?

Chase707
0
 
LVL 5

Accepted Solution

by:
Jan Louwerens earned 100 total points
ID: 7094245
I'm guessing you don't have an operator= defined for your My_Data class. Since you are using an actual object rather than a pointer to an object (extern set<My_Data> My_DataSet;), when you stick an object into the set, the operator= function is used to copy the object (My_DataSet.insert(My_Data( trackingNumber, scanInfo ));)
0
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7094247
try creating an operator= function and a copy constructor for the My_Data class
0
 
LVL 3

Expert Comment

by:MDarling
ID: 7095310
Is My_DataSet actually declared in a file in your project?

Your example simply shows it as declared somewhere externally.

0
 
LVL 1

Author Comment

by:mudface061200
ID: 7099516
It was actually a compiler issue, this was the first legitimate answer.  Thanks to all who made suggestions.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now