compile error in this code

This is a discussion on compile error in this code within the C++ Programming forums, part of the General Programming Boards category; Code: #include<iostream> #include<string> using namespace std; typedef vector<string> s1; s1 array; void func(string x); void call(string y); int main() { ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    92

    Question compile error in this code

    Code:
    #include<iostream>
    #include<string>
    using namespace std;
    
    typedef vector<string> s1;
    s1 array;
    void func(string x);
    void call(string y);
    
    int main()
    {
      string str = "abcd";
     if(str == "efg") cout<<"hello"<<endl;
    else
     {
     func(str);
      call(str);
     cout<<array[0]<<endl;
     }
    }
    
    void func(string x)
    {
    array.push_back(x);
    }
    
    void call(string y)
    {
     cout<<"i am here ";
    }

    i am getting compile error in this code.

    i want two things >

    1. why there is errors.

    2. how can i fix those errors.
    blue_gene

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >1. why there is errors.
    You forgot to include <vector>.

    >2. how can i fix those errors.
    Include <vector>
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code won't compile
    By monkles in forum C Programming
    Replies: 3
    Last Post: 05-28-2009, 01:45 PM
  2. Compile Errors in my Code. Can anyone help?
    By DGLaurynP in forum C Programming
    Replies: 1
    Last Post: 10-06-2008, 09:36 AM
  3. This code won't compile in Red Hat Linux 9
    By array in forum Linux Programming
    Replies: 7
    Last Post: 04-27-2004, 06:30 AM
  4. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Linux Programming
    Replies: 0
    Last Post: 10-14-2002, 01:30 PM
  5. How do they compile code for an OS ?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 03-27-2002, 11:16 PM

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