Discussion:
[Openexr-devel] Question about class Array
qtech qtech
2017-10-26 06:01:30 UTC
Permalink
I am an inexperienced programmer trying to build and use openexr. I think my main problem is the linking. So I have this header file:

#ifndef INCLUDED_IMF_ARRAY_H
#define INCLUDED_IMF_ARRAY_H
#include "ImfForward.h"
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
template <class T>
class Array
{
public:
Array () {_data = 0; _size = 0;}
Array (long size) {_data = new T[size]; _size = size;}
~Array () {delete [] _data;}
operator T * () {return _data;}
operator const T * () const {return _data;}
void resizeErase (long size);
void resizeEraseUnsafe (long size);
long size() const {return _size;}
private:
Array (const Array &);
Array & operator = (const Array &);
long _size;
T * _data;
};


and my main file is

#include <iostream>
#include <OpenEXR/ImfArray.h>
using namespace std;
struct C
{
C () {std::cout << "C::C (" << this << ")\n";};
virtual ~C () {std::cout << "C::~C (" << this << ")\n";};
};
int main ()
{
Array <C> a(3);

C &b = a[1];
const C &c = a[1];
C *d = a + 2;
const C *e = a;
return 0;
}


I keep getting the following error "‘Array’ was not declared in this scope"... I would really appreciate your help! Thank you in advance

<https://stackoverflow.com/questions/tagged/openexr>
Thank you,
Stelio
Paul Miller
2017-10-26 14:27:12 UTC
Permalink
Array is inside a namespace defined by the EXR headers - it's usually "Imf".

See |OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER|

So you should use Imf::Array<>.
Post by qtech qtech
I am an inexperienced programmer trying to build and use openexr. I
|#ifndef INCLUDED_IMF_ARRAY_H #define INCLUDED_IMF_ARRAY_H #include
"ImfForward.h" OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER template
<class T> class Array { public: Array () {_data = 0; _size = 0;} Array
(long size) {_data = new T[size]; _size = size;} ~Array () {delete []
_data;} operator T * () {return _data;} operator const T * () const
{return _data;} void resizeErase (long size); void resizeEraseUnsafe
(long size); long size() const {return _size;} private: Array (const
Array &); Array & operator = (const Array &); long _size; T * _data; }; |
and my main file is
|#include <iostream> #include <OpenEXR/ImfArray.h> using namespace std;
struct C { C () {std::cout << "C::C (" << this << ")\n";}; virtual ~C
() {std::cout << "C::~C (" << this << ")\n";}; }; int main () { Array
<C> a(3); C &b = a[1]; const C &c = a[1]; C *d = a + 2; const C *e =
a; return 0; } |
I keep getting the following error "‘Array’ was not declared in this
scope"... I would really appreciate your help! Thank you in advance
Thank you,
Stelio
_______________________________________________
Openexr-devel mailing list
https://lists.nongnu.org/mailman/listinfo/openexr-devel
Loading...