This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct A1 { | |
| A1(int w, int x, int y) : w(w), x(x), y(y){} | |
| int w; | |
| int x; | |
| int y; | |
| }; | |
| struct B1 : public A1 { | |
| B1(int w, int x, int y) : A1(w, x, y) {} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct A { | |
| A(int w, int x, int y) : w(w), x(x), y(y){} | |
| int w; | |
| int x; | |
| int y; | |
| }; | |
| struct B : public A { | |
| B(int w, int x, int y, int z):A(w, x, y),z(z) {} | |
| int z; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct A { | |
| A(int w, int x, int y, int z) : w(w), x(x), y(y), z(z){} | |
| int w; | |
| int x; | |
| int y; | |
| private: | |
| int z; | |
| }; | |
| int main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main () | |
| { | |
| std::map<std::string, std::string> countryCapitals { | |
| {"India", "New Delhi"}, | |
| {"Germany", "Berlin"}, | |
| {"USA", "Newyork"} | |
| }; | |
| if (auto const [itr, success] = countryCapitals.insert({"USA", "Moscow"}); success) { | |
| std::cout << "insert successful for country: " << itr->first << " capital: " << itr->second << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main () | |
| { | |
| std::map<std::string, std::string> countryCapitals { | |
| {"India", "New Delhi"}, | |
| {"Germany", "Berlin"}, | |
| {"USA", "Newyork"} | |
| }; | |
| for (auto const& [country, capital] : countryCapitals) { | |
| std::cout << country << " => " << capital << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main () | |
| { | |
| std::array<int, 3> cppArr{1, 2,3}; | |
| auto [e1, e2, e3] = cppArr; | |
| assert(e1 == 1); | |
| assert(e2 == 2); | |
| assert(e3 == 3); | |
| int cArr[] = {10, 20, 30}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct RetVal | |
| { | |
| int a; | |
| std::string b; | |
| }; | |
| RetVal doSomething() | |
| { | |
| // do something | |
| return {10, "Test"}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main () | |
| { | |
| auto t = std::make_tuple (10, 'a', "Value"); | |
| auto& [t1, t2, t3] = t; | |
| (void)t3; | |
| t1 = 20; | |
| t2 = 'z'; | |
| assert (t1 == std::get<0>(t)); | |
| assert (t2 == std::get<1>(t)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main () | |
| { | |
| auto t = std::make_tuple (10, 'a', "Value"); | |
| int t1; | |
| std::string t3; | |
| std::tie(t1, std::ignore, t3) = t; | |
| assert (t1 == 10); | |
| assert (t3 == "Value"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() | |
| { | |
| auto t = std::make_tuple(10, 'a', "Value"); | |
| auto [t1, t2, t3] = t; | |
| assert(t1 == 10); | |
| assert(t2 == 'a'); | |
| assert(t3 == "Value"); | |
| return 0; |