TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday 29 June 2020

Local Class In C++| Define Local Class In C++ | Local Class In C++ Example| Local Class In C++ Program| Explain Local Class In C++ | Local Class In C++ Syntax| Local Class In C++ In Hindi

Local Class In C++

A class declared inside a function is known as a local class in C++ as it is local to that function.

A local class name can only be used in its function and not outside it. Also, the methods of a local class must be defined inside it only. A local class cannot have static data members but it can have static functions.


image of Local Class In C++

Fig: Local Class In C++

Program:

#include<iostream.h>

#include<conio.h>

class emp;

void func()

{

class localclass

{

private:

int num;

public:

void get(int n)

{

num=n;

}

void put()

{

cout<<”the number is “<<endl;

}

};

localclass obj;

obj.get(9);

obj.put();

}

void main()

{

cout<<”demonstration of local class in c++”<<endl;

func();

getch();

}

Output:

Demonstration of local  class in c++

The number is 9

 


No comments:

Post a Comment