GeeksforGeeks

A computer science portal for geeks
Register  |  Login

Browsing the topic C/C++ Puzzles

Most of the times declarations are simple to read, but it is hard to read some declarations which involve pointer to functions. For example, consider the following declaration from “signal.h”.

Read More »

Consider the following C programs.

Read More »

Predict the output of following C++ program.

Read More »

Question: How to deallocate dynamically allocate memory without using “free()” function.

Read More »

Predict the output of following C++ program.

Read More »

Ever wondered how can you design a class in C++ which can’t be inherited. Java and C# programming languages have this feature built-in. You can use final keyword in java, sealed in C# to make a class non-extendable.

Read More »

The volatile keyword is intended to prevent the compiler from applying any optimizations on objects that can change in ways that cannot be determined by the compiler.

Read More »

Predict the output of following C++ program.

Read More »

In the virtual constructor idiom we have seen the way to construct an object whose type is not determined until runtime. 

Read More »

Can we make a class constructor virtual in C++ to create polymorphic objects?

Read More »

A class declared inside a function becomes local to that function and is called Local Class in C++. For example, in the following program, Test is a local class in fun().

Read More »

Predict the output of following program?

Read More »

The qualifier const can be applied to the declaration of any variable to specify that its value will not be changed ( Which depends upon where const variables are stored, we may change value of const variable by using pointer ).

Read More »

With GCC family of C compilers, we can mark some functions to execute before and after main().

Read More »

A typical memory representation of C program consists of following sections.

Read More »

A constructor without any arguments or with default value for every argument, is said to be default constructor. What is the significance of default constructor? Will the code be generated for every default constructor?

Read More »

In C/C++, we can assign a struct (or class in C++ only) variable to another variable of same type.

Read More »

Initializer List is used to initialize data members of a class. The list of members to be initialized is indicated with constructor as a comma separated list followed by a colon.

Read More »

When are the constructors called for different types of objects like global, local, static local, dynamic?

Read More »

In C++, variables are passed by reference due to following reasons:

Read More »

In C/C++, arrays and pointers have similar semantics, except on type information.

Read More »

In C++, the programmer abstracts real world objects using classes as concrete types. Sometimes it is required to convert one concrete type to another concrete type or primitive type implicitly. Conversion operators play smart role in such situations.

Read More »

Write a one line C function that calculates and returns . For example, if n = 64, then your function should return 6, and if n = 129, then your function should return 7.

Read More »

Predict the output of following program?

Read More »

In C++, following function declarations cannot be overloaded.

Read More »
Tweet