Re: specifying Namespace for Matrix class?
Fritz Sonnichsen <[email protected]> Fri, 15 Oct 2021 11:50:11 -0400
| Newsgroups | gmane.comp.gnu.octave.general |
|---|---|
| Message-ID | <CAMxgeAoy57wre4uW8+Wm_vFW1bTGWGJbG=9NkRqmdEHADdjurA@mail.gmail.com> |
OK and thanks. I will look around or maybe just make a special case and rename them in my old code fritz On Fri, Oct 15, 2021 at 11:41 AM Markus Mützel <[email protected]> wrote: > Maybe there are some tricks - like using wrappers - that could be used to > place those classes in a namespace for your code. > But out of the box, you pretty much hit it: These classes are in the > "base" namespace (::) and might collide with other symbols of the same name > in the "base" namespace. > > > *Gesendet:* Freitag, 15. Oktober 2021 um 16:36 Uhr > *Von:* "Fritz Sonnichsen" <[email protected]> > *An:* "Markus Mützel" <[email protected]> > *Cc:* [email protected] > *Betreff:* Re: specifying Namespace for Matrix class? > Thanks Markus for your continued help. > Regarding the Matrix Class, I am not a very strong C++ programmer-if the > class is not contained in a namespace does this mean there is no way to > specify it directly as in: > classname::Matrix .... > I have a huge amount of C++ code with the Matrix class and functions > already specified (probably should have used a different more unique > name!!!) > > Thanks again > Fritz > > On Fri, Oct 15, 2021 at 10:18 AM Markus Mützel <[email protected]> > wrote: > >> afaict, the Matrix class is currently not in a namespace: >> GNU Octave: Matrix Class Reference >> <https://octave.org/doxygen/stable/d3/d3f/classMatrix.html#adc245406f6dc2aec3953d6aba2bf69c3> >> >> HTH, >> Markus >> >> >> *Gesendet:* Freitag, 15. Oktober 2021 um 15:25 Uhr >> *Von:* "Fritz Sonnichsen" <[email protected]> >> *An:* [email protected] >> *Betreff:* specifying Namespace for Matrix class? >> I am starting with some of the octave sample code (modified below) >> calling octave from C++. I eventually will have another Matrix class in the >> code so I need to differentiate by namespace. >> I cannot find out which namespace in octave contains "Matrix" but I >> vaguely recall it is in "math". Obviously I am wrong per this error >> message: >> matr.cpp:11:17: error: ‘Matrix’ is not a member of ‘octave::math’ >> octave::math::Matrix a_matrix = Matrix (n, n); >> Any ideas which namespace it is in so I can qualify it in the code? >> >> Thanks >> Fritz >> >> =============CODE============= >> #include <iostream> >> #include <octave/oct.h> >> >> using namespace octave::math; >> >> int main (void) >> { >> std::cout << "Hello Octave world!\n"; >> int n = 2; >> octave::math::Matrix a_matrix = Matrix (n, n); >> for (octave_idx_type i = 0; i < n; i++) >> for (octave_idx_type j = 0; j < n; j++) >> a_matrix(i,j) = (i + 1) * 10 + (j + 1); >> std::cout << a_matrix; >> return 0; >> } >> ---------- We are transitioning to a web based forum for community help >> discussions at https://octave.discourse.group/c/help >> > ---------- We are transitioning to a web based forum for community help discussions at https://octave.discourse.group/c/help