Tricky One
-
Given the following:
class CEDUser
{
private:
long m_nUserID;
CString m_sName;
CString m_sDomainLogin;
COleDateTime m_dtLastLogin;
long m_nPanelID;
CString m_sPassword;public:
CEDUser(void);
virtual ~CEDUser(void);long GetUserID() { return m\_nUserID; }; CString GetDomainLogin() { return m\_sDomainLogin; }; CString GetName() { return m\_sName; }; CString GetPassword() { return m\_sPassword; ); COleDateTime GetLastLoginDate() { return m\_dtLastLogin; }; long GetPanelID() { return m\_nPanelID; }; void SetCurrentPanel(long nPanelID) { m\_nPanelID = nPanelID; }; bool LoadUser(CADODatabase\* pADO, CString sName, bool bLoggingIn); bool UpdateUser(CADODatabase\* pADO);
};
CEDUser::CEDUser(void)
{
}CEDUser::~CEDUser(void)
{
}void CEDUser::SetCurrentPanel(long nPanelID) { m_nPanelID = nPanelID; } {}
bool CEDUser::LoadUser(CADODatabase* pADO, CString sName, bool bLoggingIn) {}
bool CEDUser::UpdateUser(CADODatabase* pADO) {}Find the code that generates the following compiler errors:
1>c:\eddata\eduser.cpp(5) : error C2535: 'CEDUser::CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(17) : see declaration of 'CEDUser::CEDUser'
1>c:\eddata\eduser.cpp(16) : error C2535: 'CEDUser::~CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(18) : see declaration of 'CEDUser::~CEDUser'VC6 used to generate truly bizarre error messages when you did the same thing.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Given the following:
class CEDUser
{
private:
long m_nUserID;
CString m_sName;
CString m_sDomainLogin;
COleDateTime m_dtLastLogin;
long m_nPanelID;
CString m_sPassword;public:
CEDUser(void);
virtual ~CEDUser(void);long GetUserID() { return m\_nUserID; }; CString GetDomainLogin() { return m\_sDomainLogin; }; CString GetName() { return m\_sName; }; CString GetPassword() { return m\_sPassword; ); COleDateTime GetLastLoginDate() { return m\_dtLastLogin; }; long GetPanelID() { return m\_nPanelID; }; void SetCurrentPanel(long nPanelID) { m\_nPanelID = nPanelID; }; bool LoadUser(CADODatabase\* pADO, CString sName, bool bLoggingIn); bool UpdateUser(CADODatabase\* pADO);
};
CEDUser::CEDUser(void)
{
}CEDUser::~CEDUser(void)
{
}void CEDUser::SetCurrentPanel(long nPanelID) { m_nPanelID = nPanelID; } {}
bool CEDUser::LoadUser(CADODatabase* pADO, CString sName, bool bLoggingIn) {}
bool CEDUser::UpdateUser(CADODatabase* pADO) {}Find the code that generates the following compiler errors:
1>c:\eddata\eduser.cpp(5) : error C2535: 'CEDUser::CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(17) : see declaration of 'CEDUser::CEDUser'
1>c:\eddata\eduser.cpp(16) : error C2535: 'CEDUser::~CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(18) : see declaration of 'CEDUser::~CEDUser'VC6 used to generate truly bizarre error messages when you did the same thing.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001It looks like the member function SetCurrentPanel is declared and defined in the header file and then subsequently redefined in the compile file (.cpp I assume). Although this line looks really suspicious
John Simmons / outlaw programmer wrote:
void CEDUser::SetCurrentPanel(long nPanelID) { m_nPanelID = nPanelID; } {}
cause of the double braces?
Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]
-
Given the following:
class CEDUser
{
private:
long m_nUserID;
CString m_sName;
CString m_sDomainLogin;
COleDateTime m_dtLastLogin;
long m_nPanelID;
CString m_sPassword;public:
CEDUser(void);
virtual ~CEDUser(void);long GetUserID() { return m\_nUserID; }; CString GetDomainLogin() { return m\_sDomainLogin; }; CString GetName() { return m\_sName; }; CString GetPassword() { return m\_sPassword; ); COleDateTime GetLastLoginDate() { return m\_dtLastLogin; }; long GetPanelID() { return m\_nPanelID; }; void SetCurrentPanel(long nPanelID) { m\_nPanelID = nPanelID; }; bool LoadUser(CADODatabase\* pADO, CString sName, bool bLoggingIn); bool UpdateUser(CADODatabase\* pADO);
};
CEDUser::CEDUser(void)
{
}CEDUser::~CEDUser(void)
{
}void CEDUser::SetCurrentPanel(long nPanelID) { m_nPanelID = nPanelID; } {}
bool CEDUser::LoadUser(CADODatabase* pADO, CString sName, bool bLoggingIn) {}
bool CEDUser::UpdateUser(CADODatabase* pADO) {}Find the code that generates the following compiler errors:
1>c:\eddata\eduser.cpp(5) : error C2535: 'CEDUser::CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(17) : see declaration of 'CEDUser::CEDUser'
1>c:\eddata\eduser.cpp(16) : error C2535: 'CEDUser::~CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(18) : see declaration of 'CEDUser::~CEDUser'VC6 used to generate truly bizarre error messages when you did the same thing.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001Is it the following :- CString GetPassword() { return m_sPassword; ); Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*) -
Is it the following :- CString GetPassword() { return m_sPassword; ); Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)Nishant Sivakumar wrote:
CString GetPassword() { return m_sPassword; );
Correct.
Nishant Sivakumar wrote:
Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
I don't know why I do it. Agreed it's not necessary, but I do it anyway.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
It looks like the member function SetCurrentPanel is declared and defined in the header file and then subsequently redefined in the compile file (.cpp I assume). Although this line looks really suspicious
John Simmons / outlaw programmer wrote:
void CEDUser::SetCurrentPanel(long nPanelID) { m_nPanelID = nPanelID; } {}
cause of the double braces?
Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]
That was a mistake while typing it into the message. :) Nish found it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Nishant Sivakumar wrote:
CString GetPassword() { return m_sPassword; );
Correct.
Nishant Sivakumar wrote:
Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
I don't know why I do it. Agreed it's not necessary, but I do it anyway.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001John Simmons / outlaw programmer wrote:
Agreed it's not necessary, but I do it anyway.
Until recently I would put a semi-colon on the closing brace for a
namespace
, e.g.:namespace rec
{
...
};Until I started playing with PC-Lint, I had no idea that final semi-colon was superfluous.
Kicking squealing Gucci little piggy.
The Rob Blog -
John Simmons / outlaw programmer wrote:
Agreed it's not necessary, but I do it anyway.
Until recently I would put a semi-colon on the closing brace for a
namespace
, e.g.:namespace rec
{
...
};Until I started playing with PC-Lint, I had no idea that final semi-colon was superfluous.
Kicking squealing Gucci little piggy.
The Rob BlogAh, the joys of symbols with overloaded meanings. {} only needs a following semicolon when it's a type definition:
struct bob
{
int foo;
char bar;
};You can also declare variables there:
struct bob
{
int foo;
char bar;
} baz1, bax2;so you need the semicolon to terminate the entire statement. Leaving out that semicolon could cause some really weird behavior back in the old C days, because you could end up with this:
struct bob
{
int foo;
char bar;
}somefunc(a,b)
int a; char b;
{ ... }If you were expecting the return type of
somefunc()
to beint
implicitly, you'd be wrong because it ends up beingbob
- yes it was legal to declare a new type right in the middle of a function header. :omg:--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Is it the following :- CString GetPassword() { return m_sPassword; ); Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)Nishant Sivakumar wrote:
Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
I do this myself; I like it. If the function is a simple "getter" or "setter" and inline it makes the class definition more compact and readable.
Steve
-
Nishant Sivakumar wrote:
Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
I do this myself; I like it. If the function is a simple "getter" or "setter" and inline it makes the class definition more compact and readable.
Steve
Kinda like putting void in the parameter list for the ctor/dtor.
What's in a sig? This statement is false. Build a bridge and get over it. ~ Chris Maunder
-
Is it the following :- CString GetPassword() { return m_sPassword; ); Also why do you put ; after the {} inline function bodies? It doesn't cause any harm, but certainly an odd habit.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*) -
Given the following:
class CEDUser
{
private:
long m_nUserID;
CString m_sName;
CString m_sDomainLogin;
COleDateTime m_dtLastLogin;
long m_nPanelID;
CString m_sPassword;public:
CEDUser(void);
virtual ~CEDUser(void);long GetUserID() { return m\_nUserID; }; CString GetDomainLogin() { return m\_sDomainLogin; }; CString GetName() { return m\_sName; }; CString GetPassword() { return m\_sPassword; ); COleDateTime GetLastLoginDate() { return m\_dtLastLogin; }; long GetPanelID() { return m\_nPanelID; }; void SetCurrentPanel(long nPanelID) { m\_nPanelID = nPanelID; }; bool LoadUser(CADODatabase\* pADO, CString sName, bool bLoggingIn); bool UpdateUser(CADODatabase\* pADO);
};
CEDUser::CEDUser(void)
{
}CEDUser::~CEDUser(void)
{
}void CEDUser::SetCurrentPanel(long nPanelID) { m_nPanelID = nPanelID; } {}
bool CEDUser::LoadUser(CADODatabase* pADO, CString sName, bool bLoggingIn) {}
bool CEDUser::UpdateUser(CADODatabase* pADO) {}Find the code that generates the following compiler errors:
1>c:\eddata\eduser.cpp(5) : error C2535: 'CEDUser::CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(17) : see declaration of 'CEDUser::CEDUser'
1>c:\eddata\eduser.cpp(16) : error C2535: 'CEDUser::~CEDUser(void)' : member function already defined or declared
1> c:\eddata\eduser.h(18) : see declaration of 'CEDUser::~CEDUser'VC6 used to generate truly bizarre error messages when you did the same thing.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001IIRC you get the same error when you leave ouut the delcaration.
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers!
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify!|Fold With Us!