Vectors

This is a discussion on Vectors within the Game Programming forums, part of the General Programming Boards category; Just got back to programming after some intense FFXI. I'm picking up where I left off at and that would ...

  1. #1
    lv.42 Berserker Drake's Avatar
    Join Date
    Jun 2005
    Posts
    67

    Arrow Vectors

    Just got back to programming after some intense FFXI. I'm picking up where I left off at and that would be on vectors. I'm making a shop program where you will be able to add items to your inventory and later on sell them, but for now I just want it to display things when you type in some keywords. I'm getting errors for ISO, conflicting, and previous. Not a clue in the world what those last two were. I'm goin to put in a do while in somewhere, but thats for another day.

    code:
    Code:
    //Item Viewer v1.0
    
    #include<iostream>
    #include<string>
    #include<vector>
    #include "input.h"
    
    using namespace std;
    
    
    int main()
    {
    //Declaring Stuff
    string quit, items, shop, key;
    vector<string> inventory(10, "empty slot");
    vector<string> shop;
    shop.push_back("¤20 Ether");
    shop.push_back("¤15 Potion");
    shop.push_back("¤10 Antidote");
    
    //Welcome Player
    cout<<"Welcome to Item Viewer v1.0!"<<endl;
    cout<<"Keywords:  items, shop, and quit"<<endl;
    cout<<"\nTo see the keywords again, type key"<<endl;
    
    //input
    
    input();
    //code for input header if u need it :)
    /*
    int input()
    {
        string inpt;
        cin>>inpt;
    }*/
    
    //Ahhhh, the if statments  
            if(input() == "key")
            {
            cout<<"Keywords:  items, shop, and quit"<<endl;
            system("pause");
            }
            if(input() == "items")
            {
            system("cls");
                    for(int x = 0; x < inventory.size(); x++)
                    {
                    cout<<inventory[x]<<endl;
                    }
                    system("pause");      
            }
            if(input() == "shop")
            {
            system("cls");
                    for(int x = 0; x < shop.size(); x++)
                    {
                    cout<<shop[x]<<endl;
                    }
            }
    }

  2. #2
    Yah. Morgul's Avatar
    Join Date
    Feb 2005
    Posts
    109
    Post the exact errors, please .
    Sic vis pacum para bellum. If you want peace, prepare for war.

  3. #3
    lv.42 Berserker Drake's Avatar
    Join Date
    Jun 2005
    Posts
    67
    i dunno if i declared both of the vectors correctly. it might have something to do w/ how many i have, but i really dunno. u can try to compile it, everything is there.

  4. #4
    Yah. Morgul's Avatar
    Join Date
    Feb 2005
    Posts
    109
    I meant the errors the compilor gives you when you try to compile it. I can compile it myself later and test it though.
    Sic vis pacum para bellum. If you want peace, prepare for war.

  5. #5
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    You have declared shop twice
    Once as a vector <string>, once as a string

  6. #6
    lv.42 Berserker Drake's Avatar
    Join Date
    Jun 2005
    Posts
    67
    Quote Originally Posted by Morgul
    I meant the errors the compilor gives you when you try to compile it. I can compile it myself later and test it though.
    I posted the errors in the main thread. If you want to know which line numbers they are the first 3 lines after //Declaring Stuff.

  7. #7
    lv.42 Berserker Drake's Avatar
    Join Date
    Jun 2005
    Posts
    67
    thanks madcow, but now i only got some ISO errors and their w/ the keywords i'm trying to use. It puts ISO errors on the strings "shop", "items" and "key". I don't know if i want to declare them as strings, or if i want my input header file to declare them as strings.

  8. #8
    Yah. Morgul's Avatar
    Join Date
    Feb 2005
    Posts
    109
    I was asking for the exact compiler errors, such as:

    1>CButton.obj : error LNK2005: "int scrwidth" (?scrwidth@@3HA) already defined in 2drpgmain.obj
    That is a MSVC++ 2005 Express Edition error.
    Sic vis pacum para bellum. If you want peace, prepare for war.

  9. #9
    Registered User
    Join Date
    Nov 2005
    Posts
    14
    Could it be that you need to compile it as a multi-threaded dll/ debug - it's in code generation in the properties menu. It's just that's what it usually is when I have an error like that - two libraries have differing definitions for an object.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors
    By naseerhaider in forum C++ Programming
    Replies: 11
    Last Post: 05-09-2008, 08:21 AM
  2. How can i made vectors measuring program in DevC++
    By flame82 in forum C Programming
    Replies: 1
    Last Post: 05-07-2008, 02:05 PM
  3. How properly get data out of vectors of templates?
    By 6tr6tr in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 10:35 AM
  4. How to use Vector's in C++ !?!
    By IndioDoido in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2007, 11:13 AM
  5. Points, vectors, matrices
    By subnet_rx in forum Game Programming
    Replies: 17
    Last Post: 01-11-2002, 01:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21