POV-Ray : Newsgroups : povray.off-topic : c++ template types for function : Re: c++ template types for function Server Time
20 Oct 2021 12:38:47 EDT (-0400)
  Re: c++ template types for function  
From: Bald Eagle
Date: 30 Apr 2020 16:35:05
Message: <web.5eab364dce0a4398fb0b41570@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> typedef union foo foo;
> union foo {
>   float f;
>   bool b;
> };
>
> static foo fooarray[N];

Interesting.   I can _rationalize_ why it would be that way, but I might have
taken me days to happen upon the proper syntax.
I'll give it a whirl and see where it gets me.
Thank you very much, as always.

> in your case, the vector would be made of type foo;

Vector....   ?


> yes, I recently installed one of those C++ library-in-a-header files.  not my
> cup of tea.

So "yes" means the cpp file gets automatically referenced...

> as regards the first question, I should have thought that, for a small project,
> you can have all sensor constants etc in a single header, just a matter of
> avoiding name clashes.

So in the .h file, I have in part:
class TMP117
{
public:
 TMP117(); // Constructor

 bool begin(uint8_t sensorAddress = 0x48, TwoWire &wirePort = Wire); // Checks
for ACK over I2C, and sets the device ID of the TMP and chooses the wire port
 uint8_t getAddress();            // Returns the address of the device
 double readTempC();             // Returns the temperature in degrees C

.....

};

in the program I'm writing, I have:

TMP117 sensor;
 and
if (sensor.begin () == true) {....}

So I'm _guessing_ that "TMP117 sensor;" assigns the "keyword" sensor to - either
the class or the public constructor.

I'm also guessing the simplest way to copy-paste code to deal with multiple
sensors would be to make a new class for each sensor? ?

Is there a way to do this that will play well with treating my functions as
elements of an array?   I just want to cycle through my sensors with a loop, so
having T_C = readTempC[N](); or however the proper syntax would look would be
most preferable.

This is worse than delving into POV-Ray SDL 7+ years ago after a 10+ year
hiatus.
"Painfully stupid newbie questions."  :D  ;)


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.