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

Answer Posted / gayatri

using constructor we can initialize a class member in public
part of class.

class x
{
private: int i;

public: x()
{
i = 10;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the rules for naming an identifier?

553


How can you say that a template is better than a base class?

580


How to give an alternate name to a namespace?

587


What is struct c++?

561


Can union be self referenced?

570






Array base access faster or pointer base access is faster?

1811


How do you clear a map in c++?

565


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

607


What is the basic structure of a c++ program?

608


What is the difference between a baller and a reference in C++?

574


What is setiosflags c++?

526


Give 10 points of differences between C & C++.

619


Can c++ do everything c can?

592


Differentiate between a template class and class template in c++?

627


How can I learn dev c++ programming?

563