Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

C++ Q&A

Q. Why C&C++ programming?

Ans:- C and C++ as a general purpose programming language are on the rise for most developers. There are a lot of great usesfor C++, particularly for OS-level work, low-level work (embedded devices, device drivers, etc), certain high-performance applications, and applications where the overhead of a system like Dot Net or Java would be too heavy (like an office suite). Some developers will continue to use C and C++ for applications that other, less complex languages can handle as well. In addition, as the remaining C++ work is of higher difficulty and fewer people learn C++, expect the developers to have more job security and better compensation than Dot Net or Java developers over the long run.Scope of C & C++ programming 
  • Embedded System programming
  • Gaming industry
  • Good learning basis for all other programming languages
  • Robotics technology
  • Aeronautics science
  • Chip Designing
  • Industrial automation products

Q. Friend Function in C++.

Ans :- In OOPS data hiding is an import term, to restrict the unauthorized data accessing we make the data private and protected. But many times we need to access private or protected data of any class in that case a friend function allowed to access the private or protected data of any class.  A friend function or friend class in C++ is use for to access the private or protected data of any class from outside the class also. A friend function of any class is declared outside that class scope but it has the right to access all private and protected data/members of the class. We define a friend function from outside the class, but we have to make that function friend of any class which private or protected data want to access in that function. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.

     A Friend can be a function, function template or member of function, or a class or class template, in which case the entire class and all of its members are friend.
Syntax of friend function or class is given below:-

Friend Function:

class A
friend void show();
void show()

Friend Class

class A
friend class B;
class B


Q. What is Object-Based Programming ?

:- A object-based programming language required the following features:-
1. Data Encapsulation
2. Data hiding and access mechanisms.
3. Automatic initialization and clear-up of objects.
4. Operator overloading.
               A Language which support programming with objects are said to be object-based programming languages. But object based programming not support the Inheritance and Dynamic binding. e.g. Java Script is an object based programming language.

Object Oriented Programming = Object-Based Features + Inheritance + Dynamic Binding

Q. What is Object?

Ans:- Object is the physical and conceptual item. Object is an instance of class. Which is created from class. It is declared same like the variable.Object is a real time entity in the program. A class is a blueprint from which object has been created. When a class is declared it not take any space into memory. But when we create the object of any class, it take the space into memory. Object has the relation with class same as a variable has a relation with data type. Object is also known as the class type variable. An Object contains each member (Variable, Functions) of class, which can be access through Object using  . (dot) Operator

Q. C++ is not a Pure/Fully/Semi Object Oriented Language Why?

Ans:- C++ is a Language 'C with Classes'. To prove this that C++ is not pure/fully object oriented  there are number of reasons, some of them are discuss here. C++ has the impact of C Language, for e.g. we can write the code here without any class. We just make the code only in main() function, without any class. And main() function is not the part of any class in C++. C++ is a 'Multi-Paradigm' Programming language because in C++ we can does the both Procedural - Oriented Programming and Object - Oriented Programming. C++ also break the rules of data protection, for e.g. we can access the Private data of any class from out of Class just by using the Friend Function. There are also some other e.g. which prove that C++ is not a pure object oriented language.

So, we can say that C++ is not Pure/Fully/Semi Object Oriented Language.

Q. Write the differences between C & C++.

Ans:- Some important differences between C & C++ are describe below:-

C is Procedure/Structure Oriented Language.C++ is an Object Oriented Language
In C problem in divided into Procedures(Functions)
and then in Sub Procedures.
In C++ problem is divided into Objects.
There is less data security in C.In C++ data can be protected by Using: private,
protected or public access modifiers.
In C Variables must have to declare in the beaning of function. In C++ variable can be declare anywhere in function.
C not support the feature of Exception Handling.C++ has the feature of Exception Handling.
C follow the Top-Bottom approach.C++ follow the Bottom-Top approach
There is not feature of overloading and overriding.C++ support the overloading and overriding.
Extension of C file is ".c'.Extension of C++ file is ".cpp".
Functions are the fundamental building block in C.Objects are the fundamental building block in C++.

No comments:

Post a Comment