-
October 26th, 2010, 08:45 AM
#1
undefined reference to Struct
Code:
breachmonitor.cpp:(.text+0x17ce): undefined reference to `BreachMonitor::Breach::Breach()'
Can anyone please tell me what does it mean? I have created a struct and then declared its variable like
and it isnt compiling. The structure has default constructor (no arguments) and another one for initialization. It has also got two methods.
Code:
bool operator==(const Breach& p) const
bool operator<(const Breach& p) const
-
October 26th, 2010, 09:01 AM
#2
Re: undefined reference to Struct
Could you post a complete snippet including BreachMonitor
Victor Nijegorodov
-
October 26th, 2010, 09:04 AM
#3
Re: undefined reference to Struct
Actually it is my office work and I am afraid I wont be able to send the class but do you have any idea of what the problem could be.
Code:
struct Breach
{
string trdr; /*!< Trader itm */
string sendt; /*!< Time of message transmission */
string com; /*!< Commodity */
Breach();
Breach(const std::string& _trdr, const std::string& _sendt, const std::string& _com): trdr(_trdr), sendt(_sendt), com(_com) {}
bool operator==(const Breach& p) const
{
return trdr == p.trdr && com == p.com;
}
bool operator<(const Breach& p) const
{
if(trdr < p.trdr) return true;
if(trdr > p.trdr) return false;
if(com < p.com) return true;
if(com > p.com) return false;
return false;
}
};
-
October 26th, 2010, 09:05 AM
#4
Re: undefined reference to Struct
The default constructor for the Breach type is either not implemented, or is in a file which is not being compiled alongside the main file.
-
October 26th, 2010, 09:07 AM
#5
Re: undefined reference to Struct
How do I implement the default construct? It is inside the main() file.
-
October 26th, 2010, 09:12 AM
#6
Re: undefined reference to Struct
Victor Nijegorodov
-
October 26th, 2010, 09:14 AM
#7
Re: undefined reference to Struct
THANK YOUUUUU VICTOR . It worked .
-
October 26th, 2010, 09:15 AM
#8
Re: undefined reference to Struct
Well, the ; is unnecessary there.
-
October 26th, 2010, 09:18 AM
#9
Re: undefined reference to Struct
Originally Posted by Lindley
Well, the ; is unnecessary there.
Yes! I just forgot to delete it while updatiing the original code...
Victor Nijegorodov
-
October 26th, 2010, 09:22 AM
#10
Re: undefined reference to Struct
Thanksss
-
October 26th, 2010, 09:37 AM
#11
Re: undefined reference to Struct
Why do you use shorthand variable names that then have to be commented as to their purpose?
Code should be self-documenting as much as possible and so variables named properly go a long way towards that goal.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
October 26th, 2010, 09:54 AM
#12
Re: undefined reference to Struct
You are right. I am making changes to an already existing code. But will follow you advice while making those changes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|