I have written following program for problem 14 A(Letter):
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
int main()
{
int row,col;
char element;
cin>>row>>col;
const int cols=col;
const int rows=row;
char Array[rows][cols];
vi A;
vi B;
for(int i=0;i<row;i++)
{
for (int j=0;j<col;j++)
{ cin>>element; Array[i][j]=element;
if (Array[i][j]=='*')
{ A.push_back(i);
B.push_back(j); }
}
}
for(int i=A.at(0);i<A.at(A.size);i++)
{
for (int j=B.at(0);j<B.at(B.size);j++)
{ cout<<Array[i][j];
}
}
return 0;
}
I am getting the following compilation error which i am not able to fix....
can anybody help
Compilation Error:
In function ‘int main()’:
letter.cpp:73: error: no matching function for call to ‘std::vector<int, std::allocator<int> >::at(<unresolved overloaded function type>)’
/usr/include/c++/4.4/bits/stl_vector.h:650: note: candidates are: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::reference std::vector<_Tp, _Alloc>::at(size_t) [with _Tp = int, _Alloc = std::allocator<int>]
/usr/include/c++/4.4/bits/stl_vector.h:668: note: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp, _Alloc>::at(size_t) const [with _Tp = int, _Alloc = std::allocator<int>]
letter.cpp:75: error: no matching function for call to ‘std::vector<int, std::allocator<int> >::at(<unresolved overloaded function type>)’
/usr/include/c++/4.4/bits/stl_vector.h:650: note: candidates are: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::reference std::vector<_Tp, _Alloc>::at(size_t) [with _Tp = int, _Alloc = std::allocator<int>]
/usr/include/c++/4.4/bits/stl_vector.h:668: note: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp, _Alloc>::at(size_t) const [with _Tp = int, _Alloc = std::allocator<int>]
Thanks in advance...
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
int main()
{
int row,col;
char element;
cin>>row>>col;
const int cols=col;
const int rows=row;
char Array[rows][cols];
vi A;
vi B;
for(int i=0;i<row;i++)
{
for (int j=0;j<col;j++)
{ cin>>element; Array[i][j]=element;
if (Array[i][j]=='*')
{ A.push_back(i);
B.push_back(j); }
}
}
for(int i=A.at(0);i<A.at(A.size);i++)
{
for (int j=B.at(0);j<B.at(B.size);j++)
{ cout<<Array[i][j];
}
}
return 0;
}
I am getting the following compilation error which i am not able to fix....
can anybody help
Compilation Error:
In function ‘int main()’:
letter.cpp:73: error: no matching function for call to ‘std::vector<int, std::allocator<int> >::at(<unresolved overloaded function type>)’
/usr/include/c++/4.4/bits/stl_vector.h:650: note: candidates are: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::reference std::vector<_Tp, _Alloc>::at(size_t) [with _Tp = int, _Alloc = std::allocator<int>]
/usr/include/c++/4.4/bits/stl_vector.h:668: note: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp, _Alloc>::at(size_t) const [with _Tp = int, _Alloc = std::allocator<int>]
letter.cpp:75: error: no matching function for call to ‘std::vector<int, std::allocator<int> >::at(<unresolved overloaded function type>)’
/usr/include/c++/4.4/bits/stl_vector.h:650: note: candidates are: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::reference std::vector<_Tp, _Alloc>::at(size_t) [with _Tp = int, _Alloc = std::allocator<int>]
/usr/include/c++/4.4/bits/stl_vector.h:668: note: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp, _Alloc>::at(size_t) const [with _Tp = int, _Alloc = std::allocator<int>]
Thanks in advance...
thanks for that...
But still getting some other compilation error
Maybe you need B.at(B.size()-1)?
It is also not able to compile:
#include<iostream>
using namespace std;
int main()
{
cout<<"Testing";
return 0;
}
i am running Ubuntu 10.04....
Command which i use for compilation is :
gcc a.cpp
is there any error..
please help