Class Declaration

Hello all, after a little help with some C++ code.

I have been asked to fix a VS2005 MFC project which is missing some files (applicationdlg.cpp, application.cpp, applicationdlg.h & application.h).
So I've started by creating a new MFC project using the VS2005 wizard, then copying the generated files into the project with the missing files.
Now I am adding functionality as required to the new files.

I have these functions...
1
2
3
4
5
6
7
8
9
10
11
12
void CLcd::Init()
{
}
void CLcd::EraseBlock( UINT16 ox, UINT16 oy, UINT16 w, UINT16 h )
{
}
void CLcd::Clear()
{
}
void CLcd::ProcessDataWord( UINT16 w )
{
}

thus I created the CLcd class in application.h like...
1
2
3
4
5
6
7
8
9
class CLcd
{
	UINT16 m_x, m_y;
public:
	void Init( void );
	void EraseBlock( UINT16, UINT16, UINT16, UINT16 );
	void Clear( void );
	void ProcessDataWord( UINT16 );
};

Now what's got me stumped, sorry if this is stupid, is a few calls like ...
1
2
3
4
Lcd().ProcessDataWord( w );
Lcd().Init();
Lcd().On();
Lcd().Off();

I had thought that Lcd was an object of CLcd class but then above calls would be Lcd.Init()... Plus On() and Off() don't appear as functions of CLcd unless they were also in the missing files!

What am I missing? What is this called?
Any suggestions would be much appreciated.
Thanks.
ok calling structure was wrong.

Lcd is a class/object so it would be like this:
1
2
3
4
5
6
7

CLcd myLcd;  // create the object

// using the object
myLcd.Init();  // we init the object.
myLcd.ProcessDataWord();


the function calls of the object don't need the parentheses on the object.
Thanks Azagaros.
That's exactly what I thought (re: my original post) but in the code I have been given has parentheses. Which is why I am confused!
Last edited on
Topic archived. No new replies allowed.