Thread: compile error in this code

  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,897
    >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-28-2002, 12:16 AM