Re: Function in header file - newbie VC++/CLI




U¿ytkownik "Duane Hebert" <spoo@xxxxxxxxx> napisa³ w wiadomo¶ci
news:%23d2TeTbvHHA.5104@xxxxxxxxxxxxxxxxxxxxxxx

"Jacek" <majly@xxxxxxxxx> wrote in message
news:f6ecav$bfn$1@xxxxxxxxxxxxxxxxxx
U¿ytkownik "Duane Hebert" <spoo@xxxxxxxxx> napisa³ w wiadomo¶ci
news:uPJp7havHHA.5032@xxxxxxxxxxxxxxxxxxxxxxx

"Jacek" <majly@xxxxxxxxx> wrote in message
news:f6e758$f24$1@xxxxxxxxxxxxxxxxxx
Code in above post works good.but in next post with header file don't
work
Sorry for my english ;)

Sorry but I'm not that familliar with c++/cli.

Maybe a link like this:
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=165&rl=1

What book are you using?

This is my real problem not from book.
Thanks for reply and link. I have to learn more about this->

No, I'm wondering which book(s) you're using to learn
c++.(or c++/cli) It seems that you're confused about class structure
and member functions etc. Using the this pointer directly
doesn't actually seem to be your problem. You'd get the same
errors anyway. As I said, I don't know c++/cli but the
errors you post seem to be the same as you would get
in c++ with the same code.

Typically, in c++ at any rate, we would use
a header file to declare a class and its members
and a corresponding cpp file to define them. In the
cpp file you refer to the class's functions by using the
class's namespace.

In you case, a sort of example in c++ could be something like

//form1.h

class Form1 {

public:
Form1();
void Status(std::string Message);

};

//form1.cpp

#include "form1.h"
Form1::Form1() {
// whatever in your constructor
}


void Form1::Status(std::string Message) {

Message = "hello world";
//do something here

}


So you declare the class in the header and
do the implementation in the cpp file. Then
you create an instace of it, somewhere and use
it.

Thanks for explaination Duane. I'll print your post and hang on the wall to
remember it ;)
I read several books and many websites but not carefully I think. I learn
c++ just about 3 weeks.
I know your way to construct header . I read about it today and in first
post i try use something like this.
I'll try tommorow resolve this problem .
Thanks for advice.


.



Relevant Pages

  • Re: static library problems
    ... Do not declare variables in header files. ... variable itself must be declared in a .cpp file. ... >If i want to use this string in other modules, i just need include the header, i need not link this static lib. ...
    (microsoft.public.vc.mfc)
  • Re: should I write code in ( *.h && *.cpp ) || only *.h
    ... I wasnt doing it for fun, its just that its my first time working on a c++ ... You can't compile a header file. ... assume you have exactly one .cpp file for your whole program. ... The separation of .h and .cpp files isn't just for fun. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Nested Forward Reference (.h)
    ... > "John Carson" wrote in message ... >>> I have a set of nested classes, to which I wish to keep a forward ... >>> reference as not to include the other header file. ... History header in the .cpp file. ...
    (microsoft.public.vc.language)
  • Re: Templates with static member in header file
    ... > This will work ok if done within a single .cpp file. ... > useful such a class should be put in a header file. ... There is only a _template_ of it. ... the compiler is responsible of _merging_ all the instantiations into one ...
    (comp.lang.cpp)
  • Re: Newbie question, using classes with MFC
    ... derive a new version of CStringArray and add a copy constructor, ... My app is a simple MFC one, ... Why is the class defined in the header ... > and what should the *.cpp file contain, when the class is defined in the ...
    (microsoft.public.vc.mfc)