| www.delorie.com/archives/browse.cgi | search |
| From: | "Matt Dooner" <mdooner AT mindspring DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: gpp can't find headers |
| Date: | Sun, 9 Apr 2000 05:53:11 -0400 |
| Organization: | MindSpring Enterprises |
| Lines: | 54 |
| Message-ID: | <8cpjtm$okd$1@slb0.atl.mindspring.net> |
| References: | <8codd9$equ$1 AT slb6 DOT atl DOT mindspring DOT net> <i4f0fssllor07t7n7u7atlfefd53ftq30a AT 4ax DOT com> |
| NNTP-Posting-Host: | cf.45.30.6e |
| X-Server-Date: | 9 Apr 2000 09:52:54 GMT |
| X-Newsreader: | Microsoft Outlook Express 4.72.3155.0 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3155.0 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
The program I posted was just a test program. The bad code is what happens
when I put together something quickly with a combination of jet lag and lack
of sleep :-)
Jason Green wrote in message ...
>"Matt Dooner" <mdooner AT mindspring DOT com> wrote:
>
>> I've followed the instructions in the FAQ, but gpp still can't find my
>> included headers in c++ programs. Here is the error message from a
basic
>> program that uses a string and vector. Below it is the code of the
>> program;
>
>> #include <iostream.h>
>> #include <string.h>
>> #include <vector.h>
>
>These are old style headers. You need to use the new style if you
>want to use the string class:
>
>#include <iostream>
>#include <string>
>#include <vector>
>using namespace std;
>
>>
>> int main()
>> {
>> vector test<int>;
>
> vector<int> test;
>
>> test.resize(1);
>> string test = "test";
>
>test is already defined as type vector<int> so you can not define
>another variable of type string with the same name. It is not clear
>what you want to do here, if you wanted a vector of strings then test
>should have been defined as type vector<string>. If you want a second
>variable of type string then it must have a unique name:
>
> string str = "test";
>
>> cout << test << endl;
>
>You can not just output a vector to cout. You must iterate through
>each value contained in the vector and output them individually. You
>can still output the string though:
>
> cout << str << endl;
>
>> }
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |