Ans:
class myfolder
{
char Filenames[10][25];
long Availspace;
long Usedspace;
public:
void Newfileentry( )
{
cout<<"\nEnter any 10 file names: ";
for(int i=0;i<=9;i++)
{
cout<<"\nEnter the "<<i+1<<" file name: ";
gets(Filenames[i]);
}
cout<<"\nEnter the Available Space (In Kilobytes): ";
cin>>Availspace;
cout<<"\nEnter the Used Space (In Kilobytes): ";
cin>>Usedspace;
}
long RetavailSpace( )
{
ret Availspace;
}
void Showfiles( )
{
cout<<"\nThe names of the files in myfolder object....";
for(i=0;i<=9;i++)
{
puts(Filenames[i]);
cout<<endl;
}
}
2002:
2.a. What do you understand about a member function? How does a member function differ from an ordinary function?
Ans: A member function is a function declared within a class. It is said to be defined in two ways. Ie Outside the class and inside the class. When a member function is defined outside the class, the name of the function must be the full name including the class name as well. When a member function is defined inside the class, the name of the function is similar to an ordinary function but it will become an inline function.
2.b. Define a class Student for the following specifications.
Private members of the Student are:
roll_no | integer |
name | array of characters of size 20 |
class_st | array of characters of size 8 |
marks | array of integers of size 5 |
Percentage | float |