473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with small vector.h class

Hello,

I am working on a program to get use to the vector.h Templete class.

Program:

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

int main()
{
vector<string> v;
ifstream in("FillVector3.cpp");
string line;
while(getline(in, line))
v.push_back(line);
for(int i=0;i<v.size();i++)
cout<<i<" : "<<v[i]<<endl;
return 0;
}

It gives me 9 errors:

8 error c2784 "'declaration' : could not deduce template argument for 'type'
from 'type'"
1 error c2677 "binary 'operator' : no global operator defined which takes
type 'type' (or there is no acceptable conversion)"
Jul 19 '05 #1
2 3275
Dark Knight wrote:
Hello,

I am working on a program to get use to the vector.h Templete
class.
Template class? And please: no .h, it is called <vector>
cout<<i<" : "<<v[i]<<endl;


Look at those < signs closely. Shouldn't you have two of them everywhere?

This what I can see from the code. Since you did not share with us the line
numbers where the errors are and the concrete error messages this is the
best I can do for you now.

--
Attila aka WW
Jul 19 '05 #2

"Dark Knight" <Da************@yahoo.com> wrote in message
news:ws*******************@newsread1.news.atl.eart hlink.net...
Hello,

I am working on a program to get use to the vector.h Templete class.

Program:

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdlib>
using namespace std;

int main()
{
vector<string> v;
ifstream in("FillVector3.cpp");
if(!in)
{
cerr << "Cannot open input\n";
return EXIT_FAILURE;
}
string line;
while(getline(in, line))
v.push_back(line);
for(int i=0;i<v.size();i++)
Not the problem, but should be:

for(vector<string>::size_type i = 0; i < v.size(); ++i)
cout<<i<" : "<<v[i]<<endl;
cout << i << " : " << v[i] << endl;
return 0;
}
Note that use of whitespace as in my correction
makes these errors easier to spot, and imo
makes the code generally easier to read.

-Mike

It gives me 9 errors:

8 error c2784 "'declaration' : could not deduce template argument for 'type' from 'type'"
1 error c2677 "binary 'operator' : no global operator defined which takes
type 'type' (or there is no acceptable conversion)"

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Alan Lee | last post by:
Hi i am writing a small simulation for a bunch of atoms jumping around on a surface. I know i am a crappy programmer since i am not very familiar with object oriented languages. I am woindering...
4
by: N3TB1N | last post by:
Here is my assignment. I am hoping that someone here quickly knows all of the correct answers... especially for question #5 and everything after. Thanks in advance. ...
6
by: Charlie | last post by:
Dear all, I am stuck on this problem, couldn't find an answer on any C++ book in the bookshop. Following is a cut of my program, and its error message:...
13
by: Ben | last post by:
I have a program which is using a lot of memory. At the moment I store a lot of pointers to objects in std::vector. (millions of them) I have three questions: 1) Lets say the average Vector...
31
by: Martin Jørgensen | last post by:
Hi, I've had a introductory C++ course in the spring and haven't programmed in C++ for a couple of months now (but I have been programmed in C since january). So I decided to do my conversion...
2
nabh4u
by: nabh4u | last post by:
hi, i need some help with progamming..i have a program which has to implement gale shapley's algorithm. i have 2 preference lists one is for companies and the other is for persons. i have to match...
0
by: RLC | last post by:
Hello I am new to python SWIG. Recently I wrote a small program trying to import collada files(using colladadom) into python so I could use python cgkit to render them. However, during the...
2
by: thijo | last post by:
hi, i'm coding to take a input vector inputdata, and continuously find standard deviation to count how many distinct data ar available.for this i implement a small method called findk(). public ...
2
by: yeshello54 | last post by:
so here is my problem...in a contact manager i am trying to complete i have ran into an error..we have lots of code because we have some from class which we can use...anyways i keep getting an error...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.