473,385 Members | 1,282 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.

a decleration must be available error

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.
Jun 27 '07 #1
2 2437
sicarie
4,677 Expert Mod 4TB
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.
Jun 28 '07 #2
I have declared them in array.hpp and implemented them in array.cpp.
Jun 28 '07 #3

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

Similar topics

17
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 ;
2
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...
2
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...
0
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...
3
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; }
10
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() {
7
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...
20
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
1
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
1
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...
0
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...
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:
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: 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...

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.