New class
-
I'm trying to write a new class that is a derivative of CObject. The code all looks fine to me, but when I try to compile I get an error saying "constructor not allowed a return type", but I'm not trying to put a return type, or a return statement. Here's the code.
In ClassNameOb.cpp:
#include "stdafx.h"
#include "ClassNameOb.h"
ClassName::ClassName()
{
m_var->VarOne = m_var->VarTwo = m_var->VarThree = m_var->VarFour = m_var->VarFive = -1;
m_otherVar = -1;
}
ClassName::~ClassName(){}
In ClassNameOb.h:
class ClassName : public CObject
{
protected:
struct structType
{
int VarOne;
int VarTwo;
int VarThree;
int VarFour;
int VarFive;
}*m_var;
int m_otherVar;
public:
ClassName();
~ClassName();
}And then I get an error pointing to the line with the first { bracket of the constructor saying, "constructors not allowed a return type". Why am I getting this error when I'm not even trying to return anything? Danny The stupidity of others amazes me!
-
I'm trying to write a new class that is a derivative of CObject. The code all looks fine to me, but when I try to compile I get an error saying "constructor not allowed a return type", but I'm not trying to put a return type, or a return statement. Here's the code.
In ClassNameOb.cpp:
#include "stdafx.h"
#include "ClassNameOb.h"
ClassName::ClassName()
{
m_var->VarOne = m_var->VarTwo = m_var->VarThree = m_var->VarFour = m_var->VarFive = -1;
m_otherVar = -1;
}
ClassName::~ClassName(){}
In ClassNameOb.h:
class ClassName : public CObject
{
protected:
struct structType
{
int VarOne;
int VarTwo;
int VarThree;
int VarFour;
int VarFive;
}*m_var;
int m_otherVar;
public:
ClassName();
~ClassName();
}And then I get an error pointing to the line with the first { bracket of the constructor saying, "constructors not allowed a return type". Why am I getting this error when I'm not even trying to return anything? Danny The stupidity of others amazes me!
You need:
class ClassName : public CObject
{
...
};
"Take only what you need and leave the land as you found it." - Native American Proverb
-
You need:
class ClassName : public CObject
{
...
};
"Take only what you need and leave the land as you found it." - Native American Proverb
-
You need:
class ClassName : public CObject
{
...
};
"Take only what you need and leave the land as you found it." - Native American Proverb
The OP missed the semicolon at the end of the class declaration? Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
The OP missed the semicolon at the end of the class declaration? Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
OP? I assume you mean the compiler? In that case, yes, it missed it. How annoying! Danny The stupidity of others amazes me!
OP, I *think*, stands for Original Poster. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
OP, I *think*, stands for Original Poster. Regards Senthil _____________________________ My Blog | My Articles | WinMacro