Inline function:- C++ inline function is powerful concept that is commonly used with classes. If a function is inlined, the compiler places a copy of the code of that function at each point where the function is called at compile time. To inline a function, place the keyword inline before the function name and define […]
Author: Pawan Paudel
what is Virtual Functions? explain with example
Virtual Functions- Virtual function is member function of a class. Virtual function is declared with the keyword virtual. Virtual function takes a different functionality in the derived class. It is used to implement run time polymorphism. For example:- #include<iostream.h> #include<conio.h> Class pixeles { public: virtual void disp() { cout<<“PIXELES CLASSES FOR BCA & MCA” ; […]
xplain the Destructor in detail with the help of examples, in context of C++ programming.
Destructor :- it is also special member of class having same name but is defined with (tilde) ~ sign. It can be parameterised. It can’t be overloaded. It does not return a value even void. It is called automatically when delete an object. Example:- #include<iostream.h> #include<conio.h> classpix { public: pix() { cout<<“\n This is constructor”; […]
What is constructor? Define Book class with the basic features of a book. Define the default constructor, parameterised constructor, member functions display_book_details() for displaying the details of book. Use appropriate access control specifies in this program.
What is constructor? Define Book class with the basic features of a book. Define the default constructor, parameterised constructor, member functions display_book_details() fordisplaying the details of book. Use appropriate access control specifies in this program. Constructor Constructor is a special member function of class having same name of class It is called automatically when create […]
Explain use of any two I/O formatting flags in C++ with example.
C++ defines some format flags for standard input and output, which can be manipulated with the flags, setf, and unsetf functions. For example, cout.setf(ios_base::left, ios_base::adjustfield); void stream::unsetf(fmtflags flags); The function unsetf() uses flags to clear the io_stream_format_flags associated with the current stream. #include <iostream.h> main() { ios_base::fmtflags original_flags = cout.flags(); cout<< 812<<‘|’; cout.setf(ios_base::left,ios_base::adjustfield); cout.width(10); cout<< […]
Explain different data types available in C++ programming.
C++ supports a large number of data types. Thus built in or basic data types supported by c++ are integer, floating point and character type. A brief discussion on these three data types. 1. BUILET-IN DATA TYPES A. Integer data types (int):– it accepts numeric data such as numbers. Short Long Unsigned B. Floating point […]
What is Object Oriented Programming (OOP) paradigm? Explain basic concepts OOP.
Object-oriented programming (oop) is a programming paradigm that represents the concept of “object” that have data fields (attributes that describe the object) and associated procedures known as methods. An object can be considered a “thing” that can perform a set of related activities. The set of activities that the object performs defines the object’s behaviour. […]
write a c program to show the use of post and pre decrement function
/* using decrementer */ #include void main() { int i,j; int x,y; j = i=6; printf(” initial value i = %d\n”, j); x = i–; printf(“x= i–, value of x = %d, and value of i = %d\n”, x,i); i = j; y = –i; printf(“initial value i = %d\n”, j); printf(“y = –i, value […]
C program to show the example of post and pre Increment
/* using incrementer */ #include void main() { int i,j; int x,y; j=i=6; printf(“initial value of i = %d\n”,j); x=i++; printf(“x=i++, value of x=%d, and value of i=%d\n”,x,i); //post increment i=j; y=++i; printf(“initial value i = %d\n”,j); printf(“y=++i, value of y=%d, and value of i=%d\n”,y,i); // pre increment } run initial value of i = […]