Cygwin vector problem

From: Vish (vishalpahuja_at_hotmail.com)
Date: 12/04/03


Date: 4 Dec 2003 12:02:40 -0800

I cannot compile a simple code as below using cygwin. I believe I am
using latest version of g++(3.3.1) I get following error

is_equal.cpp:9:19: ccc.cpp: No such file or directory
is_equal.cpp:11: error: `vector' was not declared in this scope
is_equal.cpp:11: error: parse error before `>' token
is_equal.cpp: In function `bool equal_vec(...)':
is_equal.cpp:12: error: `a' undeclared (first use this function)
is_equal.cpp:12: error: (Each undeclared identifier is reported only
once for
   each function it appears in.)
is_equal.cpp:12: error: `b' undeclared (first use this function)
is_equal.cpp: In function `int main()':
is_equal.cpp:23: error: `vector' undeclared (first use this function)
is_equal.cpp:23: error: parse error before `>' token
is_equal.cpp:25: error: `cout' undeclared (first use this function)
is_equal.cpp:26: error: `cin' undeclared (first use this function)
is_equal.cpp:36: error: `v1' undeclared (first use this function)
is_equal.cpp:46: error: parse error before `>' token
is_equal.cpp:57: error: `v2' undeclared (first use this function)
is_equal.cpp:74:2: warning: no newline at end of file

/*
Vishal Pahuja
Lab 9 part 3
*/

#include <iostream>
#include <vector>
#include <stdexcept>

 bool equal_vec(vector<int> a, vector<int> b)
           { if (a.size() !=b.size()) return false;
             for (int i = 0;i<a.size();i++)
              {
                 if (a[i] != b[i]) return false;
              }
             return true;
           }

int main()

{ vector<int> v1;
   int v1size;
   cout << "\nHow many value you want to enter for vector v1?: \n";
   cin >>v1size;

    cout << "\nEnter values for vector v1: \n";
    int i,j;

    for (i = 0; i < v1size; i++)
             {
               cout << "Next: ";
               //cin >> v1[i];
               cin >> j;
               v1.push_back(j);
             }
 cout << "\nVector v1 :\n";
        for (i = 0; i < v1.size(); i++)
        {
        cout << v1[i]
        << "\n";
        }

   vector<int> v2;
   int v2size;
   cout << "\nHow many value you want to enter for vector v2?: \n";
   cin>>v2size;

    cout << "\nEnter values for vector v2: \n";
        for (i = 0; i < v2size; i++)
             {
               cout << "Next: ";
               //cin >> v2[i];
               cin >> j;
               v2.push_back(j);
             }

 cout << "\nVector v2 :\n";
        for (i= 0; i< v2.size(); i++)
        {
        cout << v2[i]
        << "\n";
        }

bool isequal;
isequal=equal_vec(v1,v2);

if (isequal) cout<< "The vectors are equal\n";
else cout<< "The vectors are not equal\n";

}



Relevant Pages

  • porting problem
    ... Socket.h:47: parse error before `)' ... Socket.h:46: conflicts with previous declaration `int Socket::sending' ... Socket.cpp:33: ANSI C++ forbids declaration `memset' with no type ... Socket.cpp:38: ANSI C++ forbids declaration `exit' with no type ...
    (comp.unix.programmer)
  • viewml cross compilation problem
    ... fltk/qstring.h:21: parse error before `int' ... fltk/qstring.h:22: parse error before `const' ... fltk/qstring.h:23: redefinition of `int m_bNull' ... fltk/qstring.h:26: non-member function `copy' cannot have `const' ...
    (comp.os.linux.embedded)
  • Re: Learning C - Scanf or Getch, or Getchar not working correctly after first loop.
    ... int busDays; ... junk.c:12: parse error before '/' token ... junk.c:12: warning: no semicolon at end of struct or union ... junk.c:58: ISO C forbids data definition with no type or storage ...
    (comp.lang.c)
  • Re: Could use some help...:)
    ... cout << endl ... int B::operator (unsigned row, unsigned column) ...
    (comp.lang.cpp)
  • Re: C++ compile error
    ... hello.C: In function `int main': hello.C:5: error: `cout' undeclared hello.C:5: error: (Each undeclared identifier is reported only once for each function it appears in.) ... cout is part of the 'std' namespace, ... I'm totally puzzled by this complex language when I compile my first program. ...
    (freebsd-questions)

Loading