Solved

Inserting into a set

Posted on 2002-06-19
5
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

729 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