I am trying to get rid of errors in a vector template. This is one of the errors.
In vector.hpp the vector template has been declared as follows:
template <class V, class I=int, class S=FullArray<V> > class Vector: public Array<V, I, S>
And in array.cpp I have implemented size() and MinIndex() functions. So when I try to use these in vector.cpp, I should not have any problems but the following code in vector.cpp gives me error.
template <class V, class I, class S>
Vector<V, I, S> Vector<V, I, S>::operator / (const V& a) const
{ // divide every element by a
// Create new vector of same size and same starting index
Vector<V, I, S> result(Size(), MinIndex());
// Copy all elements /a
for (I i = MinIndex(); i <= MaxIndex(); i++)
result[i] = (*this)[i] / a;
// Return result
return result;
}
I get the following errors:
there are no arguments to `Size' that depend on a template parameter, so a declaration of `Size' must be available
there are no arguments to `MinIndex' that depend on a template parameter, so a declaration of `MinIndex' must be available
there are no arguments to `MaxIndex' that depend on a template parameter, so a declaration of `MaxIndex' must be available
I would appreciate any insights.
2 2437
I am trying to get rid of errors in a vector template. This is one of the errors.
In vector.hpp the vector template has been declared as follows:
template <class V, class I=int, class S=FullArray<V> > class Vector: public Array<V, I, S>
And in array.cpp I have implemented size() and MinIndex() functions. So when I try to use these in vector.cpp, I should not have any problems but the following code in vector.cpp gives me error.
template <class V, class I, class S>
Vector<V, I, S> Vector<V, I, S>::operator / (const V& a) const
{ // divide every element by a
// Create new vector of same size and same starting index
Vector<V, I, S> result(Size(), MinIndex());
// Copy all elements /a
for (I i = MinIndex(); i <= MaxIndex(); i++)
result[i] = (*this)[i] / a;
// Return result
return result;
}
I get the following errors:
there are no arguments to `Size' that depend on a template parameter, so a declaration of `Size' must be available
there are no arguments to `MinIndex' that depend on a template parameter, so a declaration of `MinIndex' must be available
there are no arguments to `MaxIndex' that depend on a template parameter, so a declaration of `MaxIndex' must be available
I would appreciate any insights.
Where, in relation to that code, have you declared those functions? It looks like, from those errors, that the template class you declared is looking for those definitions as well, but I couldn't see them in there.
I have declared them in array.hpp and implemented them in array.cpp.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tapeesh |
last post by:
I would like to know what is the expected behaviour of C compilers when
an extern decleration is intialized.
When the following code is compiled using gcc
//File extern.c
int arr ;
int a ;
|
by: Janna Deegan |
last post by:
Hello all,
First off, if there is a better place to post for an answer to this
question, please feel free to point me there.
I have some very strange behavior happening with my System.web.mail...
|
by: Droopy |
last post by:
Hi,
I try to implement a reusable socket class to send and receive data.
It seems to work but I have 2 problems :
1) I rely on Socket.Available to detect that the connection is closed (no...
|
by: Husam |
last post by:
Hi EveryBody:
I got this decleration for function from URLMON.dll as follows:
<DllImport("urlmon.dll", ExactSpelling:=True, CharSet:=CharSet.Unicode)> _
Friend Shared Function...
|
by: kasiyil |
last post by:
Hello,
I have a compilation problem about namespaces:
I have a namespace X in which I declera a type definition:
In X.h file i write:
namespace X {
typedef unsigned int WindowHandle_t;
}
|
by: sam_cit |
last post by:
Hi Everyone,
I had a doubt regarding extern decleration, i tried this is one
source file,
extern int sample;
extern int sample;
int main()
{
|
by: fniles |
last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection).
I read using DataAdapter and DataSet, not DataReader.
When many people try to access the database at the same time, I get...
|
by: curious2007 |
last post by:
I have the following program:
#include "Vector.cpp"
#include <iostream>
using namespace std;
template<class Arg1, class Arg2, class Result>
struct binary_function
|
by: wanchoo |
last post by:
Hi , is
int VlanMap PROTO ( (int ulPriMap) ); a valid C declerations
My gcc 3.4.2 allows it but gcc 4.1.0 gives an error
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |