UPDATE CLOSED error: declaration of anonymous class must be a definition
-
This post original subject - error: declaration of anonymous class must be a definition was caused by this class declaration
< class REG_EXP //regular_expression_class
{
int a;
QString text;
QString RegExp;
QString Analyze;
} TEST_REG_EXP;
/pre>Search for the symbol "REG_EXP" in the entire project returned no result.
The conclusion
it is unknown why the error was posted.
Please consider this matter closed. -
This post original subject - error: declaration of anonymous class must be a definition was caused by this class declaration
< class REG_EXP //regular_expression_class
{
int a;
QString text;
QString RegExp;
QString Analyze;
} TEST_REG_EXP;
/pre>Search for the symbol "REG_EXP" in the entire project returned no result.
The conclusion
it is unknown why the error was posted.
Please consider this matter closed.What the compiler is trying to tell you is that you have an invalid function definition, namely
void PassTrace(class *Pointer);
Think about that a little bit. What is the
type
ofPointer
? If your definition ofPassTrace
(i.e. the place where you provide the code for the function) matches the given declaration, how would you access any ofPointer
's members? Does the class have membera
, or a membername
,value
? There's no way to know. Perhaps you meantvoid PassTrace(Test *Pointer)
or maybe you want a Template?
template
void PassTrace
{
// body of function
}If you know that you'll never need to test
*Pointer
for null, you might consider using areference
rather than a pointer, and if you're not going to change the contents of what Pointer points to, then consider marking it asconst
as well. Other than that, passing a pointer to a class (or struct) is no different that passing a pointer to anything else:class myClass {
// class members ...
};void f(myClass *pointer)
{
// function body
}int main()
{
myClass c;
// instantiate c's data members
f(&c); // call f with a pointer to object of type myClass
}"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
What the compiler is trying to tell you is that you have an invalid function definition, namely
void PassTrace(class *Pointer);
Think about that a little bit. What is the
type
ofPointer
? If your definition ofPassTrace
(i.e. the place where you provide the code for the function) matches the given declaration, how would you access any ofPointer
's members? Does the class have membera
, or a membername
,value
? There's no way to know. Perhaps you meantvoid PassTrace(Test *Pointer)
or maybe you want a Template?
template
void PassTrace
{
// body of function
}If you know that you'll never need to test
*Pointer
for null, you might consider using areference
rather than a pointer, and if you're not going to change the contents of what Pointer points to, then consider marking it asconst
as well. Other than that, passing a pointer to a class (or struct) is no different that passing a pointer to anything else:class myClass {
// class members ...
};void f(myClass *pointer)
{
// function body
}int main()
{
myClass c;
// instantiate c's data members
f(&c); // call f with a pointer to object of type myClass
}"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
Thank you, appreciate your reply. I did JUST modify my working test function and do not see why my definition is wrong. I am obviously missing something VERY basic here. Should it work this way ? void BT_Utility_Library::PassTrace(class *) // { // //qDebug()< // void BT_Utility_Library::PassTrace(class *Pointer) // { // //qDebug()<
-
Thank you, appreciate your reply. I did JUST modify my working test function and do not see why my definition is wrong. I am obviously missing something VERY basic here. Should it work this way ? void BT_Utility_Library::PassTrace(class *) // { // //qDebug()< // void BT_Utility_Library::PassTrace(class *Pointer) // { // //qDebug()<
void BT_Utility_Library::PassTrace(class *)
You cannot have a pointer that has no definition. The
class
keyword is usaed to define an actual class, whether abstract or not. In the definition above the pointer must be of an actual class so the compiler knows what to do with any statements that use it. -
This post original subject - error: declaration of anonymous class must be a definition was caused by this class declaration
< class REG_EXP //regular_expression_class
{
int a;
QString text;
QString RegExp;
QString Analyze;
} TEST_REG_EXP;
/pre>Search for the symbol "REG_EXP" in the entire project returned no result.
The conclusion
it is unknown why the error was posted.
Please consider this matter closed. -
Thank you, appreciate your reply. I did JUST modify my working test function and do not see why my definition is wrong. I am obviously missing something VERY basic here. Should it work this way ? void BT_Utility_Library::PassTrace(class *) // { // //qDebug()< // void BT_Utility_Library::PassTrace(class *Pointer) // { // //qDebug()<
consider:
class A { /* ... */ }
class B { /* ... */ }
class C { /* ... */ }void f(class *ptr);
Which
class
doesptr
refer to invoid f(class *ptr)
? The definition ofvoid f(class *ptr)
makes as much sense asvoid f(const i)
. There's no type associated with the parameter, so the compiler does not know what type the parameter is. Note: The use ofclass
orstruct
for a variable/parameter declaration is optional in C++ :class C { /* ... */ }
int main()
{
class C c1;
C c2;
}the declarations of
c1
andc2
are both valid, and both declare a object of typeclass C
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-