Re: [deal.II] error: cannot declare variable ‘postprocessor’ to be of abstract type ‘FracturePhaseFieldProblem<2>::Postprocessor’

24 views
Skip to first unread message

Athul Shaji

unread,
Jan 30, 2024, 11:03:24 PM1/30/24
to dea...@googlegroups.com
Hello, if you are using the PostProcessor subclass within output_results(), then is not required to use FracturePhaseFieldProblem<2>::Postprocessor as the class and the function are in the same main class FracturePhaseFieldProblem.
I think this can be the problem.

Regards,
Athul

On Wed, Jan 31, 2024 at 7:16 AM Tiny Y <yuyi...@163.com> wrote:
Hi,
I built a class called  FracturePhaseFieldProblem<dim>   , which contains a subclass called  class Postprocessor

template <int dim>

class FracturePhaseFieldProblem

{

    public:

    private:

  

void output_results () const;

class Postprocessor;

};

However when I want to declare a variable as the type FracturePhaseFieldProblem<2>::Postprocessor in function output_results (),I got the error: 

error: cannot declare variable ‘postprocessor’ to be of abstract type ‘FracturePhaseFieldProblem<2>::Postprocessor’

Thank you very much.

Best,

Yu


--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/614d3444-46ca-4d32-9172-a7a5e3bf7a7bn%40googlegroups.com.

Wolfgang Bangerth

unread,
Jan 31, 2024, 12:16:24 PM1/31/24
to dea...@googlegroups.com
Yu:

> classFracturePhaseFieldProblem
>
> {
>
>     public:
>
> …
>
>     private:
>
> …
>
> void output_results () const;
>
> class Postprocessor;

This is what's called a "forward declaration". The line really just says
"There is a class Postprocessor" but because you don't provide the
details in a {...} block, the compiler knows nothing about it.

>
> …
>
> };
>
> However when I want to declare a variable as the type
> FracturePhaseFieldProblem<2>::Postprocessor in functionoutput_results
> (),I got the error:
>
> error: cannot declare variable ‘postprocessor’ to be of abstract type
> ‘FracturePhaseFieldProblem<2>::Postprocessor’

And here the compiler is telling you "You're trying to create a variable
of this type. I know is that the class *exists*, but in order to create
a variable of this type, I need to know *what the class does* and what
its member variables are".

Best
W.
Reply all
Reply to author
Forward
0 new messages