السلام عليكم...
اخوتي الاعزاء لدي غدا اختبار مفاجئ في عدة برامج وقد حاولت حلها وتعثرت في بعض فقراتها
هذا هو السؤال:
- <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt">Define class called powerOper which has the following: <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt">Private data members x, n
- Set and Get member functions which allow assigning and returning each data member in the class. For every data member there are Set and Get functions.
[Hint: in set function you should use Validate(int) member function]
- <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt">A Constructor function that initializes the data members by using set function.
- Define a member function Power() that return the power operation.
[e.g. x=3, n=2 : Power() will return 9 which equal to(32)]
- <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt">Define member function eX() that compute and print the value of ex by using the formula: ex = 1 + x/1! + x2/2! + x3/3! +….....+ xn/n! [Hint: use nested For loop]
- Define member function Validate(int) that validate the integer if it is positive or not; if not, prompt the user to reenter it again and then return the correct positive number.
[Hint: Validate(int) should used by set member functions before setting data members to any value – use While loop]
- The program should contains Three files
§ Header file:- which contain declaration of private (data members) and public (member functions).
§ Source File 1 :- which contain the definition of your functions
§ Source File 2:- that conation your class's main.
لم أعرف كيف أعمل validate ولم أفهم الفقره 6 و7
وهذا هو حلي
#include<iostream>
using namespacs std;
class poweroper
{
private:
int x,n;
public:
poweroper(int no_x,int no_n)
{
setnumberx(no_x)
setnumbern(no_n)
}
void setenumber_x(int num_x)
{
number_ x=num_x;
}
int getrnumber_x()
{
return number_x;
}
void setnumber_n(int num_n)
{
number_n=num_n;
}
int getnumber_n()
{
return number_n;
}
int power(int xx,int yy)
{
cout<<" the operation is:"<<pow(xx,yy);
}
أرجوكم أرجو المساعده الليله