Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ Vectors

Name: Dum-bro 2010-05-14 18:21

This is my first time working with Vectors and I'm getting LNK errors
Here's my isolated code.

#include <iomanip>
#include <string>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <fstream>
using namespace std;

void input(ifstream& in, ofstream& out, vector<double> item_ID);


int main()
{
    vector<double> item_ID;
    vector<string> item_name;
    vector<double> ordered;
    vector<double> stock;
    vector<double> sold;
    vector<double> m_price;
    vector<double> o_price;
    ifstream in;
    ofstream out;

    in.open("c:\\a9data.txt");

    input(in, out, item_ID);
    system("pause");
}

void input(ifstream& in, ofstream& out, vector<double>& item_ID)
{
    in.open("c:\\a9data.txt");
}

Name: Anonymous 2010-05-14 18:26

Cool story, bro.

Name: Anonymous 2010-05-14 18:29

vectors are totally gay

Name: Dum-bro 2010-05-14 18:55

can anyone see my error? copy paste replicate?

Name: Anonymous 2010-05-14 19:10

Help us help you.  Moron.

Name: Anonymous 2010-05-14 19:13

Definition:
void input(ifstream& in, ofstream& out, vector<double> item_ID);
Implementation
void input(ifstream& in, ofstream& out, vector<double>& item_ID)

Your function declaration defines a vector<double> but your function definition uses the address of a vector<double>.  Can you do that?

Name: Anonymous 2010-05-14 19:17

>>6
Sorry, messed up the headers for the quotes even after making sure I used the right words for the comments.  The top is "Declaration;" the bottom should be "Definition."

Name: Dum-bro 2010-05-14 19:24

>>7
right on the money, it was my prototype that was the problem. now i have to actually get back to work :/
thanks bro.

Name: Anonymous 2010-05-14 19:32

:-(

Why are you doing this?

Name: Anonymous 2010-05-15 4:34

Every time I need to debug something I'm going to create a new thread.

Name: Anonymous 2010-05-15 5:02

>>10
Don't forget to deindent your code next time!

Name: Anonymous 2010-05-15 5:44

>>11
deindent? it's not intended in the first place!

Name: Anonymous 2010-05-15 12:05


    in.open("c:\\a9data.txt");

    input(in, out, item_ID);


void input(ifstream& in, ofstream& out, vector<double>& item_ID)
{
    in.open("c:\\a9data.txt");
}

Name: Anonymous 2010-05-15 20:08

void input(ifstream& in, ofstream& out, vector<double>& item_ID)
try
void input(ifstream* in, ofstream* out, vector<double>* item_ID)

Name: Anonymous 2010-05-16 0:47

Fucking newb, learn difference between

void input(ifstream& in, ofstream& out, vector<double> item_ID);
and
void input(ifstream& in, ofstream& out, vector<double>& item_ID)

Also system("pause") is shit-tier

Name: Dum-bro 2010-05-17 5:58

system("pause") is bro tier

Name: Anonymous 2010-05-17 23:56

>>15
He's right, guys.

>>16
Can go kiss my ass.

If you want to read the output of your program without your "CMD.COM", either run the program manually from "CMD" or YOU CONFIGURE YOUR IDE CORRECTLY...

The latter should be possible with visual anus, right?

Don't change these.
Name: Email:
Entire Thread Thread List