   unsure how to hold the data  [dos c++]
  To save anyone new the trouble of reading this, i've changed alot of things :)so my question is in my currentlast post. where my code is posted.Thanks.[Edited by - ryanp321 on June 27, 2009 11:06:12 AM]
Quote:Original post by ryanp321i think this belongs here beacuse its not really about game programming. its simple and the variable names are convienient for this type of file reading.i'm loading 3 text files called.findinghome.txtlostdog.txt and noquest.txt.It began me simply wanting to grab some dialouge and put it into an array.which i did simply enough, and could change which file was read depending on my current 'quest'.but i had in mind, advancing from this. and creating a class, or a structure (this is what i need help deciding) to contain my quest information.i had imagined thisclass findingHome   //name of quest{char dialouge = "findinghome.txt";}and somehow being able to accses it like, currentquest = findinghome so. currentdialouge = findinghome.dialouge;i'm not looking for code just ideas on how to store the data.When i tried running just the created class, i couldnt complile sucsesfully with the  = "finding home.txt" part still in the code.add #include <string> at the topand replace char dialogue = "findinghome.txt"; withstd::string dialogue = "findinghome.txt";(char only holds a single character)   ;  I'm almost sure you are not using dos. Maybe you are confusing the console programming in a windows environment with dos?That aside, the reason that doesn't work is twofold. One reason is given by SimonForsman, but the second (and the reason his code will not work) is that you cannot initialise class members like that.As for your code, instead of having a class per quest, consider having a single Quest class. Each quest will have its members (the dialogue, etc) populated from a particular file.As for your question on how to store the data, it depends on what your game involves. Are there a set of actions defined by the quest, is the game split into conceptual "rooms" or "areas" which the user can move to, etc?If you gave us a small example of how you would like a simple quest to play out, we could give you guidance into making your quests data driven (stored in files).   ;  Thanks rip and simonforsman.Sorry i thought dos was console programming and i thought it'd be easier to let people know that may be able to help. i'll change it now, it is console programming.I get the class problem and how to initialise it now.The idea of having a class for all quests actually will save me alot of time and space haha. Thank you for that :)as its only a text based thing.I'm just getting down a good understanding of how to use text files in c++.The next step after i've got good knowledge about this is to implement it with directx. But, as always i skip this kind of thing and fail all projects.as writing this i was trying to implement the knew ideas i have.and it just seems unordinary that i wouldnt be able to assign my objects any variable values inside of my main.h, were the class is.It will only work inside my main function.what ive got so far.class QUEST{char title;char dialogue;char requirements;};;Quote:Original post by ryanp321what ive got so far.class QUEST{char title;char dialogue;char requirements;};Still wrong. A char only holds a single character. Use std::string instead, as SimonForsman already mentioned.Also, members are private by default for classes, so your class isn't very usable at the moment. Writing a proper constructor (a public one, otherwise it's unusable!) and useful member functions would make your class much more helpful. :)Oh, and UPPERCASE names are typically used for macro's and defines, not for class names. Strictly speaking it's not wrong, but it's unnatural and can easily cause confusion for others. CamelCase names are more common.   ;  Thanks captain for the reply.class quest{public:string title;string dialogue;string requirements;};I only uppercased quest is because i couldnt camelcase it. (Thanks for that word btw :D) so is lower case more common for single words?I'm guna look up some more tutorials on class's and oop, i dont wana keep this thread too long. Thanks for the help guys.   ;  I guess it's pretty common, or capitalising the first letter only.I do it lowercase myself, ie "dialogue"if it has two words or more together, I do "dialogueText"I can never settle on a style for very long though :p   ;  Hey, im back!Here's my main.h and main.cppI've got a class, which i think is ok at the moment.Currently updating it.I'm having problems with creating a default quest.it needs to be created if theres no currentQuest.but i dont know how to show the currentQuest :/#include <iostream>#include <string>using namespace std;class quest{public: quest(string qTitle, string qRequirements, string qDialouge); ~quest(); string getQtitle(); string getQrequirements(); string getQdialogue();protected:string dialogue;string requirements;string title;};quest::quest(string qTitle, string qRequirements, string qDialogue){    title = qTitle;    requirements = qRequirements;    dialogue = qDialogue;quest none("No Current Quest","n/a","Default");quest findingHome("Finding Home","Strength+1","welcomehome");quest lostDog("Lost Dog","None","Yo,find my dog");}string quest::getQtitle(){return title;}string quest::getQrequirements(){return requirements;}string quest::getQdialogue(){return dialogue;}MAIN.CPP#include "main.h"int main(){cout << "Quest Title:" << currentQuest.getQtitle()  << endl;cout << "Quest Requirements:" << currentQuest.getQrequirements()  << endl;cout << "Quest Dialogue:" << currentQuest.getQdialouge() << endl;    system("pause");return 0;}[Edited by - ryanp321 on June 27, 2009 12:05:05 PM];  if the first half of that code is your main.h file, let me make a suggestion: get that member function implemenations the heck outta there! consider making a file quest.h and quest.cpp and in the quest.h file put the contents of main.h that describe the quest class and in quest.cpp put the member function definitions. I rewrote some of your program (mostly main.cpp) to give you some ideas on ways you can write your game.quest.h#include <string>// using namespace std;  // BAD! You force the user of your header into using // namespace standard which isn't nice. And just to save a few keystrokes!class quest{public: quest(std::string qTitle, std::string qRequirements, std::string qDialouge); ~quest(); std::string getQtitle(); std::string getQrequirements(); std::tring getQdialogue();protected:std::string dialogue;std::string requirements;std::string title;};quest.cpp#include <string>#include "quest.h"using namespace std;// using 'initializer list'. Right now you are constructing 3 std::strings, then// assigning. Cut out the assignment!quest::quest(string qTitle, string qRequirements, string qDialogue) : title(qTitle), requirements(qRequirements), dialogue(qDialogue) {}string quest::getQtitle(){return title;}string quest::getQrequirements(){return requirements;}string quest::getQdialogue(){return dialogue;}main.cpp#include <iostream>#include "quest.h"using namespace std;void printQuest(const quest &Quest){  cout << "Quest Title:" << Quest.getQtitle()  << endl;  cout << "Quest Requirements:" << Quest.getQrequirements()  << endl;  cout << "Quest Dialogue:" << Quest.getQdialouge() << endl << endl;}int main(){  quest none("No Current Quest","n/a","Default");  quest findingHome("Finding Home","Strength+1","welcomehome");  quest lostDog("Lost Dog","None","Yo,find my dog");  // You don't want to do just one quest and exit do you? keep going until the user wants to quit!  for(;;) // or while(true) if you must  {    cout << "1. Default" << endl;    cout << "2. Finding Home" << endl;    cout << "3. Lost Dog" >> endl;    cout << "4. Quit" >> endl;    cout << "Choose a quest: ";    int input;    cin >> input    // Or a switch if you prefer. I keep forgetting the syntax...    if(input == 1)    { printQuest(none);    } else if (input == 2)    { printQuest(findingHome);    } else if (input == 3)    { printQuest(lostDog);    } else if (input == 4)    { break;    } else    { cout << "Incorrect Quest Number" << endl;    }  }  return 0;}There is still a lot of room for improvement, but hopefully this will give you some ideas on how to structure your program. Some things to consider: using files to store the quest data; using std::vector or std::map to hold your collection of quests; learning about const correctness; and more!   ;  Thanks for all the effort you put into that nobody :DI understand now how to do it.But as always ^_^ theres another problem.I've got my code in two .cpp files and a .hmain.cppquest.cppquest.hAnd i can't link my main and quest to the header.I was given this link a while ago to read through http://www.gamedev.net/reference/articles/article1798.aspI even found the section which relates to my problem.I just cant get my head around the way its set out.If someone could help us out with this it'd be great, cause i know this is going to be coming up alot if i dont learn it.   