C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 19)
19.
Which of the following approach is adapted by C++?
Discussion:
27 comments Page 2 of 3.
Ashik said:
1 decade ago
It just follows the bottom-up approach. Not compulsory that it may go bottom-up any time.
Balaji Ponmuthu said:
1 decade ago
For C:
In Top Down approach main function should be at the top, ie other function definition are after main.
{..
main()
{...
..}
{ initialization,
Func()
}
For C++:
In bottom up approach we can define main anywhere in our program.
{
Initialization;
Fun()
{
}
}
main(){
..}
In Top Down approach main function should be at the top, ie other function definition are after main.
{..
main()
{...
..}
{ initialization,
Func()
}
For C++:
In bottom up approach we can define main anywhere in our program.
{
Initialization;
Fun()
{
}
}
main(){
..}
U.B.Somasekar said:
1 decade ago
Actually in C++ the execution as usually starts from main fun but one thing to observe here is the object gets created first inside the main fun which is of class type and class is always present above (top of) the main fun containing members and member fun's.
So during the time of compilation, the objects of main get created that contains separate copies of data members present in the class which is top of main and memory fun's gets shared to all object.
So first the object gets created at bottom and uses the encapsulated data memory's or memory fun's presented inside the class at top.
So during the time of compilation, the objects of main get created that contains separate copies of data members present in the class which is top of main and memory fun's gets shared to all object.
So first the object gets created at bottom and uses the encapsulated data memory's or memory fun's presented inside the class at top.
Shrondi said:
1 decade ago
Can anyone explain properly. Thats how its work in C++ and C?
Veerendra said:
1 decade ago
Why can't we write main function at the top?
Sakshi said:
1 decade ago
C follows top down approach while C++ follows bottom up approach.
In Top Down Approach, first we write the main function, that calls stubs, then subdivide these stubs in smaller stubs until a real work has to be done, that code in the final files.
In Bottom Up approach, Firstly gathering of small components that do basic actions that are required to do the full program work. Then assemble them by custom code, then assemble these parts to write the main method.
In Top Down Approach, first we write the main function, that calls stubs, then subdivide these stubs in smaller stubs until a real work has to be done, that code in the final files.
In Bottom Up approach, Firstly gathering of small components that do basic actions that are required to do the full program work. Then assemble them by custom code, then assemble these parts to write the main method.
Spjsp said:
1 decade ago
As OOP operates on classes so, if we declare main before it then there will be an error like main() has an object whose associated class is not declared.
Archana said:
1 decade ago
If the main function is defined first in c++ then what action will takes place?
Rajeev dwivedi said:
1 decade ago
Actually c is called top-down approach because in c you need to define main function then define functions. It will work. And if you define functions first then define main function, still it will work. But in oop if you define main function first then class. It will not work. Whenever we define in oop, define class then go to main function. So it is called bottom-up approach because we define main function down and go to down to up.
AMIT KKUKADIYA said:
1 decade ago
In a bottom-up approach the individual base elements of the system are first specified in great detail. These elements are then linked together to form larger subsystems, which then in turn are linked, sometimes in many levels, until a complete top-level system is formed. This strategy often resembles a "seed" model, whereby the beginnings are small, but eventually grow in complexity and completeness. However, "organic strategies", may result in a tangle of elements and subsystems, developed in isolation, and subject to local optimization as opposed to meeting a global purpose.
Object-oriented programming (OOP) is a programming paradigm that uses "objects" to design applications and computer programs. It utilizes several techniques from previously established paradigms, including inheritance, modularity, polymorphism, and encapsulation. Even though it originated in the 1960s, OOP was not commonly used in mainstream software application development until the 1990s. Today, many popular programming languages support OOP.
Object-oriented programming's roots reach all the way back to the 1960s, when the nascent field of software engineering had begun to discuss the idea of a software crisis. As hardware and software became increasingly complex, how could software quality be maintained? Object-oriented programming addresses this problem by strongly emphasizing modularity in software.
Object-oriented programming (OOP) is a programming paradigm that uses "objects" to design applications and computer programs. It utilizes several techniques from previously established paradigms, including inheritance, modularity, polymorphism, and encapsulation. Even though it originated in the 1960s, OOP was not commonly used in mainstream software application development until the 1990s. Today, many popular programming languages support OOP.
Object-oriented programming's roots reach all the way back to the 1960s, when the nascent field of software engineering had begun to discuss the idea of a software crisis. As hardware and software became increasingly complex, how could software quality be maintained? Object-oriented programming addresses this problem by strongly emphasizing modularity in software.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers