delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/09/04:45:29

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gpp can't find headers
Date: Sun, 09 Apr 2000 09:44:01 +0100
Organization: Customer of Planet Online
Lines: 46
Message-ID: <i4f0fssllor07t7n7u7atlfefd53ftq30a@4ax.com>
References: <8codd9$equ$1 AT slb6 DOT atl DOT mindspring DOT net>
NNTP-Posting-Host: modem-177.vanadium.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: news8.svr.pol.co.uk 955270559 22994 62.136.22.177 (9 Apr 2000 08:55:59 GMT)
NNTP-Posting-Date: 9 Apr 2000 08:55:59 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"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;

> }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019