ok, i decided thtat i'd be easeier to use a class, since i can just do this.
Code:
class cls
{
public:
int i;
};
cls one
cls two
and now i can use each of them as if they were compleatly diferent.
and i figured out that you can't use a number, i have to use words, which is fine, i could convert every number to that many 'a's or something. only problem is how do i tell cls that i wasn't it to be known by the value of something, instead of just something?
no my teacher didn't sugest anything else.
so with classes, and kind of re done, this works
Code:
#include <iostream>
using namespace std;
int number;
class cls
{
public:
void seti(int i);
int geti();
private:
int i;
};
void cls::seti(int i)
{
this -> i = i;
}
int cls::geti()
{
return i;
}
int main()
{
cls one;
cls two;
cout << "enter a number: ";
cin >> number;
one.seti(number);
cout << "\nenter another number: ";
cin >> number;
two.seti(number);
cout << one.geti() << " " << two.geti();
return 0 ;
}
now i'm new to classes, and i know teh including namespace std is a noob thing to do. sorry about my ineptitude.
so there is no way to instead of using "one" or "two" use a char string? i can't figure one out, but i'm still new, so maybe one of you know.
Originally Posted by
laserlight
Why cant you use an array of objects?
i don't know how, or what that is :-/