Nested Classes/Sub-Classes in C++

Started by
12 comments, last by dotnetravi 19 years, 10 months ago
quote:Original post by Drakkcon
I have no idea what "Inside() : Y(2) {}" means
It''s the constructor for the Inside class, using a member initializer list to give Y a value.

"Know Thy Programming Language!"
Advertisement
"Inside() : Y(2) {}" is just a form of constructor. It is exactly identical to saying:

Inside () { Y=2; }

It''s just putting the initializers outside of the function. This is better than initializing member variables inside the constructor but I can''t remember why...

Instead of trying to conjecture on it, I''ll just let someone else explain why it''s better.

-Auron
what does using namespace std; do?

Flamers are worst than Newbies
Flamers are worst than Newbies
Hi,

You created object to the 'foo' class and trying to access the nested class public variable. But nested class will be visible within the 'foo' class. We can access nested class memeber variables, or member functions by creating object in 'foo' class. Normally these nested class objects used pass as a param. in the main class methods. I think this will help you.

Ravi

This topic is closed to new replies.

Advertisement