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

int age=35; if(age>80) {Console.WriteLine("Boy you are old");} else {Console.WrieLine("That is a good age");}

1034


What are the uses of typedef in a program?

819


Explain stack unwinding.

847


What is format for defining a structure?

825


What is the difference between map and hashmap in c++?

796


Which c++ compiler is best?

858


describe private access specifiers?

865


What are virtual functions in c++?

914


What size is allocated to the union variable?

809


What is the maximum value of a unsigned char a) 255 b) 256 c) 128

855


Mention the purpose of istream class?

834


What is the role of static keyword for a class member variable?

867


Explain how functions are classified in C++ ?

1004


what is c++

2077


What sorting algorithm does c++ use?

883