Re: Function in header file - newbie VC++/CLI
- From: "Jacek" <majly@xxxxxxxxx>
- Date: Tue, 3 Jul 2007 23:24:28 +0200
U¿ytkownik "Jacek" <majly@xxxxxxxxx> napisa³ w wiadomo¶ci
news:f6ec30$aec$1@xxxxxxxxxxxxxxxxxx
Uzytkownik "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> napisal w
wiadomosci news:9t-dncNZl81EPRfbnZ2dnUVZ_ualnZ2d@xxxxxxxxxxxxxx
When you move the function into a cpp file you have to put the class nameIt dosen't resolve problem
in front of it:
void Form1::Status (String ^message)
{
...
}
Otherwise the compiler thinks it is a global function. I.e., not a
member of any class.
--
Scott McPhillips [MVP VC++]
Error 1 error C2653: 'Form1' : is not a class or namespace name
c:...\projects\header\header\function.h 5
For example if i make header file like this:
#pragma once
void Status (System::String ^message)
{
message = "global function";
} ;
works good. So problem isn't with that.
Problem occurs when I add to this function any command related with
controls on Form.
For example:
/// function.h
#pragma once
void Status (System::String ^message)
{
message = "global function";
this->MessageBox::Show (message);
} ;
errors:
Error 1 error C2673: 'Status' : global functions do not have 'this'
pointers c:\...\header\function.h 8
Error 2 error C2653: 'MessageBox' : is not a class or namespace name
c:\...\header\function.h 8
Error 3 error C2227: left of '->Show' must point to
class/struct/union/generic type c:\..\header\function.h 8
when i remove this-> errors are:
Error 1 error C2653: 'MessageBox' : is not a class or namespace name
c:\..\header\function.h 8
Error 2 error C3861: 'Show': identifier not found c:\..\header\function.h
8
Problem is with pointer this->. I don't know what it can
replace.
MessageBox will be work if add to header file
using namespace System::Windows::Forms;
.
- References:
- Function in header file - newbie VC++/CLI
- From: Jacek
- Re: Function in header file - newbie VC++/CLI
- From: Tom Serface
- Re: Function in header file - newbie VC++/CLI
- From: Duane Hebert
- Re: Function in header file - newbie VC++/CLI
- From: Jacek
- Re: Function in header file - newbie VC++/CLI
- From: Scott McPhillips [MVP]
- Re: Function in header file - newbie VC++/CLI
- From: Jacek
- Function in header file - newbie VC++/CLI
- Prev by Date: Re: Function in header file - newbie VC++/CLI
- Next by Date: Re: Function in header file - newbie VC++/CLI
- Previous by thread: Re: Function in header file - newbie VC++/CLI
- Next by thread: Re: Function in header file - newbie VC++/CLI
- Index(es):
Relevant Pages
|