Solved

Inserting into a set

Posted on 2002-06-19
5
224 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using Delphi code in a Builder project that uses a DLL 3 114
Fully specialized class template function 21 136
c++ syntax question 9 48
Path to  STL Map header file 1 58
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

770 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