Local Classes in c++





This video tutorial explains the local classes in c++.
You are gonna learn what are local classes, how to define local classes, how to access local class members, what is the scope of local class, how to use local classes in your program in detail with example.

source code for this tutorial

#include <iostream>
#include <string>

using namespace std;
void studentList();
int main()
{
    studentList();

     return 0;
}

void studentList(){
class Student{
public:
    string name;
    int age;

    void display(){
    cout <<name <<endl<<age<<endl;
    }
};

Student anil;
anil.name = "anil";
anil.age = 24;
anil.display();
}

 
Back To Top