
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

797 Views
We use gcc and g++ compilers in different times. Here we will see what are the differences between gcc and g++.The gcc is GNU C compiler, and g++ is GNU C++ compiler. The main differences are like below −gcc can compile *.c or *.cpp files as C and C++ respectivelyg++ can also compile *.c and *.cpp files, but take both as C++ fileIf we want to use g++ to link the object files, it automatically links in the STD C++ libraries. The gcc does not do thatgcc compiles C files which has fewer predefined macrosgcc compiles C++ files with more ... Read More

31K+ Views
To compile a C++ program with GCC, we need to download GCC or install the g++ compiler on our system. Otherwise, you will not be able to compile C++ code using GCC. What is GCC? The GCC is a tool chain that compiles code. It stands for GNU Compiler Collection, which was developed by the GNU project. The GCC supports various programming languages such as C, C++, Go, etc. Specific to the C++ language, the GCC provides the g++ compiler, which is developed or designed to compile the C++ source code into executable programs. Note: When the C++ program compiles ... Read More

2K+ Views
Here we will see how to prevent inheritance in C++. The concept of preventing inheritance is known as the final class. In Java or C#, we can use final classes. In C++ there are no such direct ways. Here we will see how to simulate the final class in C++. Approach Firstly, we will create one extra class called MakeFinalClass (its default constructor is private). This function is used to solve our purpose. The main Class MyClass can call the constructor of the MakeFinalClass as they are friend classes. One thing ... Read More

185 Views
Sometimes we may see some numeric literals, which is prefixed with 0. This indicates that the number is octal number. So octal literals contain 0 at the beginning. For example, if an octal number is 25, then we have to write 025.Example#include int main() { int a = 025; int b = 063; printf("Decimal of 25(Octal) is %d", a); printf("Decimal of 63(Octal) is %d", b); }OutputDecimal of 25(Octal) is 21 Decimal of 63(Octal) is 51

162 Views
Here we will see some incompatibilities between C and C++. Some C codes that can be compiled using C compiler, but does not compile in C++ compiler. And also returns error.We can define function using a syntax, that optionally specify the argument types after the argument list.Example#include void my_function(x, y)int x;int y; { // Not valid in C++ printf("x = %d, y = %d", x, y); } int main() { my_function(10, 20); }Outputx = 10, y = 20OutputError in C++ :- x and y was not declared in this scopeIn C, or some older version of C++, the ... Read More

273 Views
Here we will see the effect of nextafter() and nextforward() functions in C or C++. These functions are present in the math.h or cmath library.if the functions are like nextafter(a, b) and nextforward(a, b). These functions are used to find the next representable value after a in the direction of b. The nextforward() has more precise second parameter b.Example#include #include main () { //The nextafter function() printf ("Smallest representable number after 0 towards 1 : %e", nextafter(0.0, 1.0)); printf ("Largest representable number before -1 towards 0 :%e", nextafter(0.0, -1.0)); printf ("Largest +ve representable number ... Read More

1K+ Views
In C++, there is no direct way to check the environment architecture. There are two Macros for Windows systems, that can be used to check the architecture. These macros are _WIN64, and _WIN32. When the system is 64-bit, then the _WIN64 will be 1, otherwise the _WIN32 will be 1. So using macro checking, we can identify the architectureExample#include using namespace std; int main() { #ifdef _WIN64 cout

17K+ Views
A const member variable in a C++ class is a data member whose value must be initialized during object construction and cannot be modified. Initializing Const Member Variable in C++ Class The const member variable must be initialized. To initialize a const member variable, you can use a member initializer list using a constructor, . The member initializer list is the special way to initialize the values to class variables while creating an object before the constructor block runs. Note: If the member is static and of an integer type, you can directly initialized with the class definition. ... Read More

14K+ Views
The CTRL + C is used to send an interrupt to the current executing task. In this program, we will see how to catch the CTRL + C event using C++.The CTRL + C is one signal in C or C++. So we can catch by signal catching technique. For this signal, the code is SIGINT (Signal for Interrupt). Here the signal is caught by signal() function. Then one callback address is passed to call function after getting the signal.Please see the program to get the better idea.Example#include #include #include #include using namespace std; // Define ... Read More

7K+ Views
Here we will see, how to terminate the threads in C++11. The C++11 does not have direct method to terminate the threads.The std::future can be used to the thread, and it should exit when value in future is available. If we want to send a signal to the thread, but does not send the actual value, we can pass void type object.To create one promise object, we have to follow this syntax −std::promise exitSignal;Now fetch the associated future object from this created promise object in main function −std::future futureObj = exitSignal.get_future();Now pass the main function while creating the thread, pass ... Read More