Which of the following approaches is used by C++?
2023
Which of the following approaches is used by C++?
- A.
Left-right
- B.
Top-down
- C.
Bottom-up
- D.
More than one of the above
- E.
None of the above
Attempted by 231 students.
Show answer & explanation
Correct answer: D
C++ supports both top-down and bottom-up programming approaches. Top-down design involves breaking a program into smaller functions starting from the main function, which is common in C++ for modular programming. Bottom-up design involves building small components like functions or classes first and then integrating them, which is also supported in C++. Therefore, C++ uses both approaches.
Top-down fits well with object-oriented design: define classes, public interfaces, virtual methods, and derive concrete implementations later.
Bottom-up fits with template libraries, low-level data structures, and utility components that get composed into higher-level abstractions.
Language features (namespaces, templates, RAII, OOP, inline functions) support both approaches: design interfaces in headers (top-down) and implement efficient primitives in source or header (bottom-up).
हिन्दी उत्तर: C++ टॉप-डाउन और बॉटम-अप दोनों प्रोग्रामिंग दृष्टिकोणों का समर्थन करता है। टॉप-डाउन डिज़ाइन में प्रोग्राम को मुख्य फ़ंक्शन से शुरू करके छोटे-छोटे फ़ंक्शनों में तोड़ना शामिल है, जो मॉड्यूलर प्रोग्रामिंग के लिए C++ में आम है। बॉटम-अप डिज़ाइन में पहले फ़ंक्शन या क्लास जैसे छोटे घटकों का निर्माण करना और फिर उन्हें एकीकृत करना शामिल है, जो C++ में भी समर्थित है। इसलिए, C++ दोनों दृष्टिकोणों का उपयोग करता है।
टॉप-डाउन ऑब्जेक्ट-ओरिएंटेड डिज़ाइन के लिए उपयुक्त है: क्लास, पब्लिक इंटरफ़ेस, वर्चुअल मेथड को परिभाषित करें और बाद में ठोस कार्यान्वयन प्राप्त करें।
बॉटम-अप टेम्प्लेट लाइब्रेरी, निम्न-स्तरीय डेटा संरचनाओं और उपयोगिता घटकों के लिए उपयुक्त है जिन्हें उच्च-स्तरीय अमूर्तताओं में संयोजित किया जाता है।
भाषा की विशेषताएं (नेमस्पेस, टेम्प्लेट, RAII, OOP, इनलाइन फ़ंक्शन) दोनों दृष्टिकोणों का समर्थन करती हैं: हेडर में इंटरफ़ेस डिज़ाइन करना (टॉप-डाउन) और स्रोत या हेडर में कुशल प्रिमिटिव को लागू करना (बॉटम-अप)।