2004:
2.b) Declare a class myfolder with the following specifications:
Private members of the class:
Filenames an array of strig of size[10][25] .(to represent all the names of files inside myfolder)
Availspace long.
(to represent total number of bytes available in myfolder)
Usedspace long. (to represent total number of bytes used in myfolder)
Public members of the class:
Newfileentry() : A function to accept values of Filenames, Availspace and Usedspace from user.
Retavailspace(): A function that returns the value of total kilobytes available(1 kilobyte=1024 bytes)
Showfiles(): A function that displays the names of all the files in myfolder
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 inmyfolder 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.
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )