下記のような、クラスで作成したvoidをランダムにシャッフルすることはできないのでしょうか?どなたかご教授いただけると嬉しいです。
該当のソースコード
C++
1#include <algorithm> 2#include <iostream> 3#include <vector> 4#include <numeric> 5#include <iterator> 6#include <random> 7#include <string> 8#include <windows.h> 9 10class test 11{ 12public: 13 void test::test_t() 14 { 15 std::string str = "おはよう"; 16 17 std::cout << str << std::endl; 18 Sleep(3000); 19 } 20 void test::test_e() 21 { 22 std::string str2 = "こんにちは"; 23 24 std::cout << str2 << std::endl; 25 Sleep(3000); 26 } 27 void test::test_s() 28 { 29 std::string str3 = "こんばんは"; 30 31 std::cout << str3 << std::endl; 32 Sleep(3000); 33 } 34}; 35 36test tes; 37int main() 38{ 39 std::vector<void> v{ tes.test_t,tes.test_e,tes.test_s }; 40 41 std::mt19937 e{ std::random_device{}() }; 42 std::shuffle(v.begin(), v.end(), e); 43 std::copy(v.begin(), v.end(), std::ostream_iterator<void> 44 (std::cout)); 45 std::cout << std::endl; 46 47}
補足情報(FW/ツールのバージョンなど)
使用しているのはvisual studio2017です。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/19 08:55