C++ Programming Questions

What is C++?

C++ is a general purpose programming language developed by Bjourne Stroustrup at Bell Laboratories during 1983-1985 as a superset of the C language. It has object oriented and generic programming features, while also providing facilities for low-level memory management. C++ to date is one of the most widely used, powerful programming languages. It perhaps surpasses any other programming language in performance even today, with other object oriented languages around like Java.

What is an Object?

An object is a representation of a type that holds data and allows operations to be performed on it self. An Object lets us describe our concept, type or idea in terms of data and methods.

Thus becomes a basis for a modular analysis of our problem. The whole problem and solution domain can be represented in terms of objects; objects can interact with themselves producing results. Read the answer to the question a What is Class? To understand objects better.

What is a Class?

Objects of the same type fall into a Class. Consider for example a Car. A Car can be represented as a Class with a state variable of price and methods like Stop, Move etc.

Now Mercedes can be an object of type or class Car with a price of $XX, whereas Buick can be an Object of type or Class Car with price of $YY. Hence Objects of a Class are similar except for their state.

What is Polymorphism?

In OOP terms, polymorphism represents the ability to resolve a reference to an object’s method at run time. Specifically, different objects could make a call to a Draw or Print method, and these methods would act differently with each object; the process can take different forms behind a common interface. One of the benefits of polymorphism is that because the interface is common to objects, any object is able to respond differently to some common set of tasks, and objects are independent of each other.

What is Object Oriented Programming (OOP)?

Object-Oriented Programming (OOP) is an approach to program organization and development that attempts to eliminate some of the pitfalls of conventional programming methods by in incorporating the best of structured programming features with several powerful new concepts. It is a new way of organizing and developing programs and has nothing to do with any particular language. However, not all languages are suitable to implement the OPP concepts easily.

What is Inheritance?

In object-oriented programming of computer science, an inheritance is a way to form new classes (instances of which will be objects) using pre-defined objects or classes where new ones simply take over old ones’s implementations and characteristics. It is intended to help reuse of existing code with little or no modification.
The term originates with the biological concept of a parent passing on certain traits to a child.

What is Encapsulation?

Programming errors can be minimized if data can be changed only in a well regulated way. Encapsulation is a means of enforcing such regulation, by allowing access to the data only through a class interface. This is also known as data hiding.

What are Constructors and Destructors?

A constructor in C++ is a special method that is created when the object is created or defined. This particular method holds the same name as that of the object and it initializes the instance of the object whenever that object is created. The constructor also usually holds the initializations of the different declared member variables of its object. Unlike some of the other methods, the constructor does not return a value, not even void.

As opposed to a constructor, a destructor is called when a program has finished using an instance of an object. A destructor does the cleaning behind the scenes. Like the default constructor, the compiler always create a default destructor if you don’t create one. Unlike the default constructor, a destructor also has the same name as its class by preceding the class name with a tilde (~).

What are Virtual Functions?

A virtual function a member function which is declared within base class and is re-defined (Overridden) by derived class. Virtual methods are declared by adding the virtual keyword to the function’s declaration in the base class. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class’s version of the function. The implementation that is executed when you make a call to a virtual function depends on the type of the object for which it is called. This is determined at run time.

What is an Abstract Classes?

In object-oriented programming, a class designed only as a parent from which sub-classes may be derived, but which is not itself suitable for instantiation. Often used to “abstract out” incomplete sets of features which may then be shared by a group of sibling sub-classes which add different variations of the missing pieces.

What are Copy Constructors?

In C++, a constructor that takes an instance of the class as its parameter and sets the data members to match the value of that instance.

What is Operator Overloading?

Use of a single symbol to represent operators with different argument types, eg “-” used either as a monadic operator to negate an expression or as a dyadic operator to return the difference between two expressions. Another example of operator overloading is “+” used to add either floating-point numbers or matrices. Overloading is also known as ad-hoc polymorphism.

What is Function Overloading?

In C++, function overloading is a technique in which two or more functions with the same name are distinguished from one another by differing semantics. Overloaded functions enable programmers to supply these semantics for a function, depending on the types and number of arguments.

What are Inline Functions?

In C++ inline function is a programming language construct used to suggest to a compiler that a particular function be subjected to in-line expansion; that is, it suggests that the compiler insert the complete body of the function in every context where that function is used. Mainly inline functions are used to increase the execution time of a program.

 

If you are stuck with your C++ assignments then you can always hire the best C++ experts from the internet and get help with C++ homework.

M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post