On Jul 3, 6:06 pm, "Jacek" <m...@gazeta.pl> wrote:
Uzytkownik "gpuchtel" <gpuch...@gmail.com> napisal w wiadomoscinews:1183493728.356726.205700@n2g2000hse.googlegroups.com...
On Jul 3, 12:28 pm, "Jacek" <m...@gazeta.pl> wrote:
Hello
I'm very 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.
'this' exists only in the context of a class. Did you forget to
specify the class name?
void YourClassName::Status (System::String ^message)
{
}
I don't want new class, only global function.
Yes, I agree wiht 'this' but what have to replace it ?
A reference (or pointer) to an (object) instance of a class.
.