typedef and enum — C++ MCQs

30
Score: 0
Attempted: 0/30
1. What does typedef do in C++?



2. Which of the following is a correct syntax for typedef?



3. After typedef int Integer;, which statement is correct?



4. Which of the following can be used with typedef?



5. What is the purpose of enum in C++?



6. Which of the following is a correct enum declaration?



7. What is the default value of the first enumerator in an enum?



8. Can you assign specific values to enum members?



9. What will be the value of Blue in enum Color { Red=2, Green, Blue };?



10. How do you declare a variable of an enum type?



11. Can typedef be used with enum?



12. What is output?
enum Color { Red, Green, Blue };
Color c = Green;
cout << c;




13. Can enum members have negative values?



14. Can enum values be used in switch statements?



15. Can typedef create alias for pointer types?



16. Can you declare multiple typedefs in one line?



17. Can enums be forward-declared?



18. What is output?
enum Numbers { One=1, Two, Three };
cout << Three;




19. Can enum type variables be assigned integer values directly?



20. Which of the following is true about typedef?



21. What will be the value of Yellow in enum Color { Red=1, Green=3, Blue, Yellow=7, Pink };?



22. Can typedef be used with arrays?



23. Can enum values overlap?



24. Can typedef be used with function pointers?



25. Can enum type be used as a function argument?



26. Which of the following is correct typedef for pointer to function returning int?



27. Can enums be scoped in C++11 using enum class?



28. Which is true about enum class in C++11?



29. Can typedef rename a struct?



30. Which of the following statements about typedef and enum is true?



Contents Copyrights Reserved By T4Tutorials