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

Which software is best for c++ programming?

806


Write a program to add three numbers in C++ utilizing classes.

881


How do you flush a buffer in c++?

835


Explain the problem with overriding functions

859


What do you mean by early binding?

827


What is increment operator in c++?

791


Can you use the function fprintf() to display the output on the screen?

984


What is the use of lambda in c++?

802


Do inline functions improve performance?

858


What is the difference between #import and #include?

814


How static variables and local variablesare similar and dissimilar?

840


What does it mean to declare a member function as static?

847


What is the use of bit fields in structure declaration?

774


Evaulate: 22%5 a) 2 b) 4 c) 0

889


What are pointers used for c++?

828