Re: Two questions - thanks!
From: Scuro (crsoft_at_questolevalo.libero.it)
Date: 11/24/04
- Next message: Jonathan Mcdougall: "Re: Static member and namespace - a puzzle."
- Previous message: Victor Bazarov: "Re: constructor"
- In reply to: Chutian: "Two questions - thanks!"
- Next in thread: Chutian: "Re: Two questions - thanks!"
- Reply: Chutian: "Re: Two questions - thanks!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 24 Nov 2004 00:39:06 +0100
Chutian wrote:
> What's the best way to share data between classes?
To share data between objects of the same class i suggest to use a
static data, to share data between two different classes, there are many
solutions. One quite elegant solution, if it makes sense, is to inherit
from a common superclass that shares the data.
> What's the purpose of define a member function in a class as 'static'? Just
> for it to access static member variables? Is there any other reasons?
From "thinking in C++":
"static member functions
You can also create static member functions that, like static data
members, work for the class as a whole rather than for a particular
object of a class. Instead of making a global function that lives in
and “pollutes” the global or local namespace, you bring the
function inside the class. When you create a static member
function, you are expressing an association with a particular class."
- Next message: Jonathan Mcdougall: "Re: Static member and namespace - a puzzle."
- Previous message: Victor Bazarov: "Re: constructor"
- In reply to: Chutian: "Two questions - thanks!"
- Next in thread: Chutian: "Re: Two questions - thanks!"
- Reply: Chutian: "Re: Two questions - thanks!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|