(Note: The correct mailing list for this type of question is
[email protected] )

In general, using pointers to class methods doesn't really work like
you would expect.... the reason?  Because you have to have a class
instance to call it on... meaning you have to store two pieces of
data... the pointer to the method and a pointer to a class instance.
Here is some reading on the subject:

http://www.parashift.com/c++-faq-lite/pointers-to-members.html

I do believe that you can do exactly what you were suggesting if you
make the function "static".... but at that point you might as well
just make it external to the class because a static member function
can't access any data internal to the class anyway...

Basically, the answer is no...

Derek


On Jan 14, 2008 5:51 AM, Mathias Nenning <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm programming a Newmarksystem...
>
> My question is, if it is possible to attach a "assemble function" which
> is a method of a class...
>
> Example:
>
> PoroNewmark
> {
> private:
> // declaration of a function pointer
> void (PoroNewmark::*funcP)( EquationSystems &es, const std::string&
> system_name );
> public:
> //...
> //...
> void MatrixAssembler( EquationSystems &es, const std::string& system_name );
>
> };
>
> PoroNewmark::PoroNewmark (...)
> {
> //...
> //...
> funcPtrAssembler = & PoroNewmark::MatrixAssembler
>
> rNewmark_system.attach_assemble_function ( funcPtrAssembler);
>
> //...
> //...
> }
>
> This will giva a comilation error
>
> $ make
> creating dependencies for src/poro_newmark.C ...
> make[1]: Entering directory `/../main'
> compiling src/poro_newmark.C ...
> src/poro_newmark.C: In constructor 'PoroNewmark::PoroNewmark(const
> inp::Input*, Mesh*, MeshData*, Material*, Analysis*, MeshOptions*)':
> src/poro_newmark.C:78: error: no matching function for call to
> 'NewmarkSystem::attach_assemble_function(void
> (PoroNewmark::*&)(EquationSystems&, const std::string&))'
> /opt/libMesh/libmeshOPT/include/solvers/system.h:450: note: candidates
> are: void System::attach_assemble_function(void (*)(EquationSystems&,
> const std::string&))
> make[1]: *** [poro_newmark.o] Error 1
>
> Any suggestions?
>
> Thanks in advance
> Mathias
>
>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to