New and Delete Operators in C++

This C++ Program which demonstrate using keywords new and delete. The program dynamically allocates a pointer to int using keyword ‘new’, deletes it using keyword ‘delete’ and is set to NULL. We are required to set the pointer to NULL since it prevents further use of the pointer. Here is source code of the C++ … Read more

advertisement

C++ Program to Allocate Memory using new[ ] and delete[ ]

This C++ program illustrates memory allocation and de-allocation using new and delete keywords. The space for one-dimensional and two-dimensional arrays can be allocated and de-allocated using these keywords. In case of two-dimensional array, the array first allocated is that for holding pointers to further one-dimensional arrays. Here is the source code of the C++ program … Read more

advertisement

C++ Program to Demonstrate the use of Access Control Specifiers

This C++ program illustrates the use of access control specifiers in a class. The three access control specifiers are as follows : public – member is visible to the user and derived classes, private – member is not visible to the user and derived classes and protected – member is visible to the derived class … Read more

advertisement

C++ Program to Find Size of Primitive Data Types

This C++ Program which prints size of primitive datatypes. The program uses a library function sizeof( ) to print the size of the respective datatypes. The output streams are manipulated using the library functions setw( ) and setfill( ) defined in the header ‘iomanip’. Here is source code of the C++ program which prints size … Read more

advertisement

Primitive Data Types in C++

This C++ Program which reads in the values of different primitive datatypes. The program uses input streams to take in the values of the primitive datatypes. Here is source code of the C++ program which reads in the values of different primitive datatypes. The C++ program is successfully compiled and run on a Linux system. … Read more

advertisement

C++ Program to Print Pointer Size of Data Types

This C++ program prints the sizes of pointers to primitive datatypes like int, float, double and long. The size of the pointers is implementation dependent and should be same for every primitive datatype since it contains the same of data. The sizeof operator is used for determining the size of the datatypes. Here is the … Read more

advertisement

C++ Program to Demonstrate the use of Namespaces

This C++ Program which demonstrates the use of namespaces. The program creates two namespaces with a variable of same name defined in each of them but with different data type. The functions functionOne( ) and functionTwo( ) take an integer as an input and save in the variable “val”. The values of “val” are printed … Read more

advertisement

Pass by Reference in C++

This C++ program illustrates how to pass a variable to a function by reference. The value of the parameter can be changed by using this method. The referencing operator (&) is used in the function definition only and not when the function is called like in pointers where the address was passed whenever the function … Read more

advertisement

Pass by Value Program in C++

This C++ program illustrates how to pass a variable to a function by value. The value of the parameter can not be changed by using this method since we do not pass the variable’s address by either referencing operator (&) or using pointer. Here is the source code of the C++ program illustrates how to … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.