What is Nested Class ? How Can We Define and Declare Nested Classes ?

No comments



Nested Class :-  Classes  can be defined inside other classes. Classes that are defined inside other classes are called nested classes. A class can be nested in every part of the surrounding class, in the public, protected and private section. Such a nested class can be considered a member of the surrounding class. The normal access and visibility riles in classes apply to nested classes.

Example :- 

class surround
{
public:
class firstwithin
{
public:
firstwithin ();
int getvar () const
{
return (variable);
}
private:
class secondwithin
{
public:
secondwithin ();
int getvar () const
{
return (variable);
}
private:
int variable;
};

No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀