C++ : should main() b defined compulsarily?can it b inside a class? also in array c[]={1,2,3} what will be c[1]?
define a class to represent a book in a library with datamembers: book number, Book Name, Author, Publisher,Price, no. of copies, No.ofcopies issued.
member function : (i) to assign initial values (ii) issues book after checking for its availability.
(iii) to return a book. (iv) to display book information.
Define a class ELECTION with the following speciations. with a suitable main() fumction also to declare 3 objects of ELECTION type %26amp; find the winner %26amp; display the details.
private members: candidate_name, party, votes_received
public memberfumctions: enterdetails()-input data
Display()- to display winner
winner()- to return details of the winner through the object after comparing the votes received by the 3 candidates.
2 simple programs in C++. %26amp; also a basic doubt. please make it simple as i am a beginner.?
"C++ : should main() b defined compulsarily"
Not sure what you mean.
"can it b inside a class?"
Not in C++, no it must be global. You can do this though:
int main(int argc, char **argv)
{
return Program.Main(argc, argv);
}
static class Program
{
static int main(int argc, char **argv)
{
return 0;
}
}
"also in array c[]={1,2,3} what will be c[1]?"
Arrays in C are 0-based, so c[1] is the second element, in this case the value is 2.
The rest of your questions sound like homework and I'm not going to ruin your learning experience.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment