|
[Sponsors] |
December 17, 2014, 14:58 |
Pointer Initialization
|
#1 |
New Member
Stefanie
Join Date: Oct 2014
Posts: 7
Rep Power: 12 |
Hi,
I am still new in OpenFOAM and I'm having issues initializing a pointer of the type autoPtr<scalar>&. I declared a protected variable and a public function to access the value it is gonna point to in functions that belong to other classes Code:
autoPtr<scalar>& BtTrans_; inline autoPtr<scalar>& BtTrans(); Code:
template<class CloudType> inline Foam::autoPtr<Foam::scalar>& Foam::MyEvaporationAS<CloudType>::BtTrans() { return BtTrans_; } Now in the constructor of my class I wanted to initialize BtTrans_ like so: Code:
BtTrans_(NULL) Code:
BtTrans_(0.0) error: invalid initialization of non-const reference of type `Foam::autoPtr<double>&’ from an rvalue of type ‘double’ Maybe one of you can help me with his/her thoughts on this issue?! Thanks so much, Stef EDIT: I've found the error. The declaration of BtTrans_ was incorrect. Should have been: Code:
autoPtr<scalar> BtTrans_; Now I have issues assigning the pointer to the variable I want it to point to. How do I do that correctly? Code:
template<class CloudType> void Foam::MyEvaporationAS<CloudType>::calculate(...) const { Bt= 5.0; BtTrans_ = &Bt; } The error I'm getting is the following: error: no match for ‘operator=’ in ‘((const Foam::MyEvaporationAS<Foam::ReactingCloud<Foam::Th ermoCloud<Foam::KinematicCloud<Foam::Cloud<Foam::R eactingParcel<Foam::ThermoParcel<Foam::KinematicPa rcel<Foam:article> > > > > > > >*)this)->Foam::MyEvaporationAS<Foam::ReactingCloud<Foam::T hermoCloud<Foam::KinematicCloud<Foam::Cloud<Foam:: ReactingParcel<Foam::ThermoParcel<Foam::KinematicP arcel<Foam:article> > > > > > > >::BtTrans_ = & Bt’ Last edited by SprayStef; December 18, 2014 at 16:02. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFD by anderson, chp 10.... supersonic flow over flat plate | varunjain89 | Main CFD Forum | 18 | May 11, 2018 08:31 |
FMG initialization query | Mohsin | FLUENT | 6 | November 2, 2016 03:02 |
Segmentation Fault caused by a pointer | floquation | OpenFOAM Programming & Development | 1 | October 17, 2014 12:43 |
CFX temperature initialization | jp_ | CFX | 3 | August 28, 2014 10:06 |
PtrDictionary: pointer with structure (order) of mesh | maybee | OpenFOAM Programming & Development | 0 | February 11, 2014 05:27 |