Function in header file - newbie VC++/CLI
- From: "Jacek" <majly@xxxxxxxxx>
- Date: Tue, 3 Jul 2007 19:06:37 +0200
Hi All,
I'm newbie in programing and first time try move function to header file.
I have simple function declered on Form1.h
void Status (String ^message){
this->richTextBox1->AppendText(message+"\n");
this->richTextBox1->ScrollToCaret(); }
it's work good on this form i.e on event button.click :
Status ("Hello world");
I'd like move this function to header file function.h and function.cpp
In file function.h are declaration like this:
#pragma once
void Status (System::String ^message);
In file function.cpp I added body of the function:
#include "function.h"
#include "stdafx.h"
void Status (System::String ^message){
this->richTextBox1-> AppendText(message+"\n");
this->richTextBox1-> ScrollToCaret();
};
Unfortunately it doesn't work. I lost a lot of time to resolve error but
without result.
I don't know how replace pointer this->
Error from VC++:
..\function.cpp(11) : error C2673: 'Status' : global functions do not have
'this' pointers
..\function.cpp(11) : error C2227: left of '->richTextBox1' must point to
class/struct/union/generic type
..\function.cpp(11) : error C2227: left of '->AppendText' must point to
class/struct/union/generic type
..\function.cpp(12) : error C2673: 'Status' : global functions do not have
'this' pointers
..\function.cpp(12) : error C2227: left of '->richTextBox1' must point to
class/struct/union/generic type
..\function.cpp(12) : error C2227: left of '->ScrollToCaret' must point to
class/struct/union/generic type
Where I made error ? Please help.
.
- Follow-Ups:
- Re: Function in header file - newbie VC++/CLI
- From: Ben Voigt [C++ MVP]
- Re: Function in header file - newbie VC++/CLI
- From: Tom Serface
- Re: Function in header file - newbie VC++/CLI
- Prev by Date: Re: VC++7.1 to 8.0 change, casting NaN or infinity to integer differs
- Next by Date: Re: Function in header file - newbie VC++/CLI
- Previous by thread: Re: Module definition file problem
- Next by thread: Re: Function in header file - newbie VC++/CLI
- Index(es):