using delete operator on this
Can we use delete operator on this inside a class member function in C++, something like below: class TestClass { public: void myFunc() { delete this; } };
comma operator
Comma in C and C++ comes in two flavours As separator (used to separate parameters in a function call) As operator (rarely used) The two flavors are as different as it can be. Lets discuss them one by one:
Order of evaluation of operands
What will be the output of the below code in C or C++ language? int x = 0; int a() { x = 10; return 2; } int b() { x = 20; return 3; } main() { int y = a() + b(); printf(“%d”, x); }
Should we use user-defined type conversions
Yesterday I talked about what are user-defined conversions and how Single Argument constructor and overloaded type conversions operators act as type conversions from a Class (user-defined type) to any other type and vica-versa. Today’s questions is more like a design question, C++ provide us the functionality to define user-defined type conversions, but should is it […]
User-defined type conversions in C++ (Single argument constructor & implicit type conversion operators function)
There are 2 types of user-defined conversion functions in C++ – Single Argument constructor. – implicit type conversion operators. Explain them
value of i++ + ++i or ++i + i ++
If the initial value of i is 2 What is the value of expression i++ + i++?