Hello again, alone I've managed to get my program up and working and directed any little questions to my lecturer. I'm sorry that last time it seemed my statement was ambiguous for anyone that thought I needed code. So here I'll make it quite brief. I simply need to find out why my program is not outputting during this while statement.
I'll only provide the sections of my code needed for the statement.
#include <iostream>
usingnamespace std;
#ifndef FUN_H
#define FUN_H
class Fun
{
public:
Fun(longint number)//Overload Constructor(sets newNumber to Number entered)
{
newNumber=number;
}
longint power(int base, int exponent)
{
int count; //Loop counter.
int newBase; //Used so the original base can remain as the figure entered.
count=1;
newBase=1;
while (count <= exponent)
{
newBase*=base;
++count;
}
return newBase;
}
/*long int getnewNumber()//Displays the number that was entered (only for assuring the code is working)
{
return newNumber;
}*/
void leTable()
{
int numbero=0;
while(numbero >=10)
{
cout<<power(numbero,1)<<"\t"<<power(numbero,2)<<"\t"power(numbero,3)<<endl;
++numbero;
}
}
private:
//Member Variable
longint newNumber;
};
#endif
.CPP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
#include "fun.h"
int main()
{
Fun Thisobject;
Thisobject.leTable();
return 0;
}
If im missing any parenthesis symbols outside of the while loop its simply a copy and paste error. Besides that I'm more worried about why I'm not getting any output unless I declare it outside of the loop.
int numbero=0;
while(numbero >=10) {
cout<<power(numbero,1)<<"\t"<<power(numbero,2)<<"\t"power(numbero,3)<<endl;
++numbero;
}
Zero is assigned to numbero when the member function(method) is called. The while loops condition is only true if numbero is more than or equal to ten, which it is not. There's your problem. To fix it, simply change the while loops condition to while(numero <= 10).
(I want to go hang myself right now) Need to relearn preschool style, sorry I overlooked the whole big fish small fish concept with the angle brackets. Thanks and I'll try to keep my questions as specific as this next time. Again thanks so much.