CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

dimensionedScalar as class member

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 27, 2013, 04:04
Default dimensionedScalar as class member
  #1
New Member
 
Cedric
Join Date: Mar 2013
Posts: 2
Rep Power: 0
Seeker is on a distinguished road
Hi!

I am trying to write a small class. I feel like this should be trivial, but I can't figure out how to get a dimensionedScalar as a class member without errors =/.

I would like to have something along the lines of:
Code:
class A {
    public:
        A();
        ~A() {};
        dimensioned<scalar> getX() {return dimX; } //Edited
    private:
        dimensioned<scalar> dimX();
}

//Constructor
A::A () {
    dimX.name() = "dimX";
    dimX.dimensions() = dimLength;
    dimX.value() = 0.0;
}
Instead of having a dimensionedScalar, I can of course just have a double as class member and than have a dimensionedScalar created and returned when getX() is called... but that's really not pretty =).

The error I am getting is "error: ‘((A*)this)->A::dimX’ does not have class type"

What am I missing?
Thanks!

Last edited by Seeker; March 29, 2013 at 06:58.
Seeker is offline   Reply With Quote

Old   March 28, 2013, 14:40
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Is that the actual code you're trying to compile?

Your function getX has no return value and the member variable dimX should not have brackets after it for a start.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   March 29, 2013, 06:57
Default
  #3
New Member
 
Cedric
Join Date: Mar 2013
Posts: 2
Rep Power: 0
Seeker is on a distinguished road
Hi
Thanks for the reply

I typed it up in here, forgot to copy the returntype, thanks.

Quote:
member variable dimX should not have brackets after it for a start.
That's the way I had it at the beginning too. In this case however, without brackets I get this:
error: no matching function for call to ‘Foam::dimensioned<double>::dimensioned()’

I looked up the source code and found that a NULL constructor is called with empty brackets, which seems to work. However, I cannot seem to be able to assign any value afterwards.
Seeker is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 12:39
Doxygen documentation Tanay OpenFOAM Installation 9 September 23, 2011 12:40
member function [value()] of dimensioned<Type> class sblee1977 OpenFOAM Programming & Development 2 November 9, 2010 04:52
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30


All times are GMT -4. The time now is 07:26.