My class syntax is invalid - but I don't understand!!!

Here's the code - it says unresolved symbol.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <time>
class PAINTER
{
public: 
PAINTER();
~PAINTER();
int bd;
short caga;
void NullPaint(const char *FAILED);
}; PAINTER PNT 
using namespace std;
void Paint(char *IM);
int main(int args, char**LOC[])
{
char nCaga = '&';
const char *PASS;
Paint(&nCaga);
}
void Paint()
{
char spill;
if(spill != '0x0FF')
{
PNT::NullPaint(&PASS);
}
}
PNT::NullPaint(const char *FAILED)
{
try
{
catch(short  dw);
}
}
Last edited on
What's the actual error message? They do tell you what the problem is, you just need practice reading them - can you post it here?

Cheers,
Jim
Is it related to Paint()?

Line 18 is calling Paint() but you don't define it until line 20.
Either move the definition of Paint() before you use it, or put a forward declaration in before you use it:

 
void Paint(); // Forward decl - defines function interface, but not body. 


You're also missing a closing brace from the try block in PNT::NullPaint

Cheers,
Jim
closed account (zb0S216C)
You haven't provided definitions for "PAINTER::PAINTER( )" and "PAINTER::~PAINTER( )".

1
2
3
4
5
6
7
8
9
10
// Definition for PAINTER::PAINTER( ):
PAINTER::PAINTER( )
  : bd( 0 ), caga( 0 ) // Initialiser-list
{
}

PAINTER::~PAINTER( )
{
  // The explicit destructor isn't necessary.
}

"PNT" cannot be used to provide definitions for member-functions as it's not a type-identifier. In order to define a member function outside of the class, you must qualify the member-function's identifier with the class' name of which it's a member of. For example:

1
2
3
4
void PAINTER::NullPaint( const char *FAILED )
{
  //...
}

It's just like a normal function definition except that the function's name is prefixed with the class' name and then the SRO (::), or Scope Resolution Operator.

Wazzak
You're also calling the methods in PAINTER incorrectly.

Line 25,
PNT::NullPaint(&PASS); should be PNT.NullPaint(&PASS);

The <class>::<method>() type call is for calling static methods on a class, not methods on an object.

Also, while we're on line 25, PASS is defined in main(), so it's not visible to Paint() where you're trying to use it.

AND PASS is defined as a const char*, so you don't need to use &PASS, just PASS will do. If you use &PASS you're ending up with a const char**, not a const char* as NullPaint() expects. So line 25 now becomes (once Paint() can see PASS):

PNT.NullPaint(PASS);

Actually, there's plenty wrong here - line 11 is misformed - you need a ';' on the end.

Also, your definition of NullPaint should be PAINTER::NullPaint(), not PNT::NullPaint() - PNT is an instance/object of the PAINTER class.

Cheers,
Jim
Last edited on
Some indenting in the code would help, too!
Topic archived. No new replies allowed.