Quote:
Original post by Zahlman
That's not a reason, and to be honest you're making less and less sense. Please, I'm trying to make this easier for you. Why resist that?
Please dont take me the wrong way. Im not resisting you in anyway, infact im incredibly gracious for your help. You have to be patient with me as this is my first real programing language and ive only been at this since a few weeks before project 1 was assigned. I know what I want to do, but unfortunately I dont know how to convey it.
If you look at how I did the menu system in my first project, you might get a sense at how im approaching this. clickie
The idea is for my menu system to dynamically build itself based on the users location in the world. Each location is its own object stored in a multi array. There will be menu object pointers belonging to each object that will be used to create a custom menu based on where the user is. This idea will also be ported over to the item/container system.
That being said, im still working on concepts before I can start coding for project 2. The largest concept being vectors and reading/writing from/to a file.
After your posts I went back and cleaned up the code and came close to what I want...
#include <fstream>#include <string>#include <vector>#include "object.h"#include <iostream>using namespace std;int main(){ vector <Object*> Objv; ifstream fin("test.csv"); // open the file std::string objtext; int objid; while (fin>>ws && getline(fin,objtext,',') && fin>>objid) { Object *newobj=new Object(objtext,objid); Objv.push_back(newobj); } // end end of line while fin.close(); std::string word; int id; int size=Objv.size(); for (int i=0; i<size; i++) { word=Objv->Getchar(); id=Objv->Getid(); cout << "Its word: " << word << " and its id: " << id << endl; } for(int i=0; i<size; i++) { delete Objv; } char ch; cin >> ch; //just a stop break before exiting console return 0;}
This works and compiles fine... but I want a pointer to the Objv vector. I tried this below, but the word=Objv->Getchar() and Getid() break and want a "." instead.
vector <Object*> *Objv;Objv=new vector <Object*>;
Also, cin and cout will not work unless i #include <iostream>... but I thought iostream was included in fstream. What did I miss there? Even dropped the using namespace and tried std::cin..etc