Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > nested class forward declaration

Reply
Thread Tools

nested class forward declaration

 
 
n.torrey.pines@gmail.com
Guest
Posts: n/a
 
      02-28-2007
I'm curious, is this legal C++ ? `g++ -pedantic -ansi -Wall` gives no
warnings.

struct s {
char c;
s(char c) : c(c) {}
void f() const;
private:
struct i; // !!!
};

struct s::i {
float f;
i() : f(0) {}
};

void s::f() const {
i ii;
std::cout << ii.f << c << '\n';
}

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      02-28-2007
wrote:
> I'm curious, is this legal C++ ? `g++ -pedantic -ansi -Wall` gives no
> warnings.
>
> struct s {
> char c;
> s(char c) : c(c) {}
> void f() const;
> private:
> struct i; // !!!
> };
>
> struct s::i {
> float f;
> i() : f(0) {}
> };
>
> void s::f() const {
> i ii;
> std::cout << ii.f << c << '\n';
> }


Yes, it is. Why wouldn't it be legal?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Marcus Kwok
Guest
Posts: n/a
 
      02-28-2007
wrote:
> I'm curious, is this legal C++ ? `g++ -pedantic -ansi -Wall` gives no
> warnings.
>
> struct s {
> char c;
> s(char c) : c(c) {}
> void f() const;
> private:
> struct i; // !!!
> };
>
> struct s::i {
> float f;
> i() : f(0) {}
> };
>
> void s::f() const {
> i ii;
> std::cout << ii.f << c << '\n';
> }


FWIW, Comeau online compiled it with no errors in strict mode either.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Forward declaration and nested classes .. Susan Baker C++ 1 07-07-2005 01:25 PM
Forward declaration of a nested class Jiri Palecek C++ 2 07-26-2004 09:46 PM
forward declaration of a structure nested in a class Stephane Routelous C++ 5 02-19-2004 09:41 PM
Re-forward declaration of types which were already forward declared qazmlp C++ 1 02-15-2004 07:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57