473,378 Members | 1,609 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,378 software developers and data experts.

How to fix "Vector.hpp:271:70: error:" errors?

So here's the thing....I ve been stuck with these errors for almost one and a half day.I couldnt find any solutions.I am working on class template of Vector for its functionality....i have interfaces in vector.h file
and I have included Vector.h file in my .hpp file(where I have designed my class template for Vector)
But still this error is persistent.


Vector.hpp:271:70: error: ‘bool Vector<T>::operator==(const Vector<T>&, const Vector<T>&)’ must take exactly one argument

I am also getting the same error for != and << operator.

Here is the code snipped of how I have defined them in interface file and in class template file.
Definitions in interface file.
Expand|Select|Wrap|Line Numbers
  1. template <typename T>
  2. bool operator==(const Vector<T> & lhs, const Vector<T> &rhs);
  3.  
  4. template <typename T>
  5. bool operator!=(const Vector<T> & lhs, const Vector<T> &rhs);
  6.  
  7. template <typename T>
  8. std::ostream & operator<<(std::ostream &os, const Vector<T> &v);
  9.  
Actual functions...
Expand|Select|Wrap|Line Numbers
  1. template <typename T>
  2. bool Vector<T>::operator==(const Vector<T> & lhs,const Vector<T> &rhs) {
  3. some code...
  4. }
  5.  
  6. template <typename T>
  7. bool Vector<T>::operator!=(const Vector<T> & lhs, const Vector<T> &rhs) {
  8.     some code....
  9. }
  10.  
  11. template <typename T>
  12. ostream& Vector<T>:: operator<<(std::ostream &os,const Vector<T> &v) {
  13. some code
  14. }
  15.  

Any hints/directions as regarding this will be much appreciated..

Thanks in advance.
Feb 7 '11 #1
1 1934
horace1
1,510 Expert 1GB
I think for a template class operator==(), etc must be member functions not global friends, e.g.
Expand|Select|Wrap|Line Numbers
  1. bool operator==(const Vector<T> & lhs);
Feb 8 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Srini | last post by:
Hello, Rules for inline functions say that they have to be defined in the same compilation unit as their declarations. For class member functions this means that the inline member functions must...
2
by: He Shiming | last post by:
Hi, I've got a question regarding class inheritance. The following code reproduces the problem I'm dealing with: class IBase { public: virtual void Method(void)=0; };
10
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what...
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
2
by: Matt Kruse | last post by:
Let's say I want to create two (or more) global functions from within a closure, so they can both share some "private" variables and methods. What is the recommended way to do this? (function(){...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
7
by: beginner | last post by:
Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. "my module...
6
by: jthep | last post by:
Hi I'm trying to write a JNI for a linkedlist class I wrote in C++. Basically I have a header file with the class definition and a C++ file with the definition of the class member functions. I...
2
by: shatemo5 | last post by:
Hi, I'm new in C++ programimng :( & I have a couple of questions to ask about :- 1- I have to build 5 clases & in each one I have to overide the opretaros new & delete ...so in each time I call...
5
emaghero
by: emaghero | last post by:
I have the following class declaration class class_name{ public: class_name(); // Constructor // Member functions void function_1(); void function_2(double *mat); void...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.