Class function C++

fmmctg01's Avatar, Join Date: Mar 2011
Go4Expert Member
How can i random add number using class function in C++ program?
0
Alvasin's Avatar, Join Date: Apr 2011
Light Poster
A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions.

An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.

Classes are generally declared using the keyword class, with the following format:

class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
} object_names;

Where class_name is a valid identifier for the class, object_names is an optional list of names for objects of this class. The body of the declaration can contain members, that can be either data or function declarations, and optionally access specifiers.
fmmctg01 like this
0
Avenger625's Avatar, Join Date: Feb 2011
Go4Expert Member
I did not quite get your question!!!
Please elaborate on exactly what you want.....
0
fmmctg01's Avatar, Join Date: Mar 2011
Go4Expert Member
1. Save classFraction in a file called classFraction.cpp.
2. Write the main function in a file called fractionExercises.cpp. You access class
Fraction through the statement: #include “classFraction.cpp”. The main function consists
of a do while loop that displays the following menu:
*************************************
What type of exercise would you like to see?
+, -, * , or /
*************************************
The user enters their choice (+, -, * , or /) into a variable named choice. If choice is
‘*’, then a function called multFraction() is called. This function is not part of class
Fraction. It is found in the same file as the main function.
Function multFraction() generates a random multiplication exercise. Use: srand(time(0)),
and rand()%15+1, to generate random integers between 1 and 15. Functions srand and
rand are found in stdlib.
0
Avenger625's Avatar, Join Date: Feb 2011
Go4Expert Member
Okay! And after that what do u want to do?????

And, just a personal question....if u dont mind me asking your nationality...i mean where do u live?
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
DO NOT post duplicate threads please. One thread per subject.
http://www.go4expert.com/showthread.php?t=25791
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by xpi0t0s View Post
DO NOT post duplicate threads please. One thread per subject.
http://www.go4expert.com/showthread.php?t=25791
Thread closed.