Date: Thu, 17 Oct 1996 15:19:51 -0600 (MDT) From: Nate Williams <nate@mt.sri.com> To: hackers@freebsd.org Subject: C++ question Message-ID: <199610172119.PAA20617@rocky.mt.sri.com>
next in thread | raw e-mail | index | archive | help
Any C++ gurus out here? If so, here's a small snippet of a program that I am having some questions on. ------------cut here--------------- class foo { public: foo() {}; private: struct A { int bigint; }; struct B { A *ptr; // Sun's C++ compiler doesn't like this }; A myints; A *getint(void); }; #if __GNUC__ foo::A * // G++ requires this, but Sun's compiler gets lost #else A * // I prefer G++'s syntax above, but can't for Sun #endif foo::getint(void) { return ( &myints ); } ------------cut here---------------- The above snippet of code compiles fine with g++ and *all* warnings turned on, but gives the following warning with Sun's CC compiler (latest released version). fly:/tmp % CC +w -c grpdgram.cc "grpdgram.cc", line 12: Warning (Anachronism): foo::A is not accessible from foo::B. It's only a warning, but according to the documentation I'm doing something that won't be allowed in future C++ releases. All I'm trying to do is define a structure, and then using the resulting definition in another structure. (It's used for *simple* list processing in the real code, and I have a place-holder for multiple lists in another structure). I know how to get rid of the warnings with the particular application (be more 'object oriented';), but I would think using two structures would be allowed in C++. Any clues? Finally, I find it interesting that G++ and Sun's CC compiler have completely different function declaration syntax when you return structures defined inside the function. Nate
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610172119.PAA20617>