সি++ nested
🌈সি++ nested কি?
📋সি++ nested হলো নেস্টেড রেন্ডার করার পদ্ধতি।
⚒️সি++ nested নেস্টেড রেন্ডার করতে ব্যবহৃত হয়।
সি++ nested নেস্টেড রেন্ডার করার উদাহরণ।
cpp
#include <iostream>
#include <map>
#include <string>
#include <variant>
using namespace std;
using Value = variant<
string,
map<string, string>
>;
int main() {
map<string, Value> user = {
{"নাম", "মোঃ আরিফ"},
{
"তথ্য",
map<string, string>{
{"স্বপ্ন", "সফটওয়্যার ইঞ্জিনিয়ার"},
{"দেশ", "বাংলাদেশ"}
}
}
};
cout << "<table border='1'>";
cout << "<tr>";
cout << "<th>নাম</th>";
cout << "<td>" << get<string>(user["নাম"]) << "</td>";
cout << "</tr>";
cout << "<tr>";
cout << "<th>তথ্য</th>";
cout << "<td>";
cout << "<table border='1'>";
cout << "<tr>";
cout << "<th>স্বপ্ন</th>";
cout << "<td>"
<< get<map<string, string>>(user["তথ্য"])["স্বপ্ন"]
<< "</td>";
cout << "</tr>";
cout << "<tr>";
cout << "<th>দেশ</th>";
cout << "<td>"
<< get<map<string, string>>(user["তথ্য"])["দেশ"]
<< "</td>";
cout << "</tr>";
cout << "</table>";
cout << "</td>";
cout << "</tr>";
cout << "</table>";
return 0;
}