C++ Vectors
1
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");
}
2
Name:
Anonymous
2010-05-14 18:26
Cool story, bro.
3
Name:
Anonymous
2010-05-14 18:29
vectors are totally gay
4
Name:
Dum-bro
2010-05-14 18:55
can anyone see my error? copy paste replicate?
5
Name:
Anonymous
2010-05-14 19:10
Help us help you. Moron.
6
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?
7
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."
8
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.
9
Name:
Anonymous
2010-05-14 19:32
:-(
Why are you doing this?
10
Name:
Anonymous
2010-05-15 4:34
Every time I need to debug something I'm going to create a new thread.
11
Name:
Anonymous
2010-05-15 5:02
>>10
Don't forget to deindent your code next time
!
12
Name:
Anonymous
2010-05-15 5:44
>>11
deindent? it's not intended in the first place!
13
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");
}
14
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)
15
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
16
Name:
Dum-bro
2010-05-17 5:58
system("pause") is bro tier
17
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?