Data member in C++ by R4R Team

What is Data member?
Data type inside class are called as data member.

How make Data member and call and use?

program:

#include< iostream>

using namespace std;
class myclass
{
public:
int n=10;
float f=1.34;
char s[20]="Mystring";
};
int main()
{
myclass obj;
cout<< obj.n<< endl;
cout<< obj.f<< endl;
cout<< obj.s<< endl;
return 0;
}


output-

10
1.34
Mystring




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!