Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Class function C++ (http://www.go4expert.com/forums/class-function-cpp-t25790/)

fmmctg01 14May2011 22:10

Class function C++
How can i random add number using class function in C++ program?

Alvasin 15May2011 17:06

Re: Class function C++
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 {
} 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.

Avenger625 15May2011 23:17

Re: Class function C++
I did not quite get your question!!!
Please elaborate on exactly what you want.....

fmmctg01 15May2011 23:20

Re: Class function C++
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.

Avenger625 15May2011 23:41

Re: Class function C++
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?

xpi0t0s 17May2011 11:48

Re: Class function C++
DO NOT post duplicate threads please. One thread per subject.

shabbir 17May2011 15:04

Re: Class function C++

Originally Posted by xpi0t0s (Post 83111)
DO NOT post duplicate threads please. One thread per subject.

Thread closed.

All times are GMT +5.5. The time now is 04:02.