Code:
#include<iostream>
using namespace std;
#include <vector>
class Object{
public:
Object(int, int);
void printDetails();
private:
int x;
int y;
};
Object::Object( int xnum, int ynum)
{
x = xnum;
y = ynum;
}
void Object::printDetails()
{
cout << x << " , " << y;
}
int main()
{
vector<Object*>lolvector;
for ( int z = 0; z != -1; z++) //starting for loop
{
int x, y;
cout << "x = ?"; //reading in the variables
cin >> x;
cout << "y = ?";
cin >> y;
Object *intptr;
intptr = new Object(x,y);
lolvector[z] = intptr;
}
}
Right so. Im trying to take input from the keyboard and insert it into objects to which then i am filling a vector with pointers to these objects. Can anyone see anything wrong with this. I ask as i cant figure out how to even test it. I thought it would be along the lines of :
lolvector[1].printDetails();
But it gives me errors and i cannot find any information on it in my notes so any help would be appreciated.
TY ocuk
Firthy