How do you initialize a class member,
class x {
const int i;
};

Answer Posted / harminder

It can be done in the intialization list of the constructor

x():i=10
{
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you call C functions from C++ and vice versa?

650


What is #include cmath?

670


What are put and get pointers?

593


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

619


What are the defining traits of an object-oriented language?

705






Explain some examples of operator overloading?

658


What is a .h file c++?

539


Explain the isa and hasa class relationships. How would you implement each?

624


What is boyce codd normal form in c++?

702


Explain dangling pointer.

689


What do you mean by function pointer?

609


In c++, what is the difference between method overloading and method overriding?

609


Differentiate between a copy constructor and an overloaded assignment operator.

649


What do you mean by translation unit in c++?

689


Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.

2100