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

syntax error

template <class Type>
class Array
{
public:
explicit Array(int size = DefaultArraySize);
Array(Type *array, int array_size);
Array(const Array &rhs);

virtual ~Array() {delete [] ia;}

bool operator==(const Array &) const;
bool operator!=(const Array &) const;

virtual Type &operator[](int index) {return ia[index];}
virtual void sort();

virtual Type min() const;
virtual Type max() const;
virtual int find(const Type &value) const;

protected:
static const int DefaultArraySize = 12; // <----- problem, compiler says
illegal pure syntax, must be 0.
// Why wont my
compiler let this go?
//My book says
this is ok as long as it's "static const int".

int _size;
Type *ia;
};
Jul 23 '05 #1
6 4667
Andy White wrote:
template <class Type>
class Array
{
public:
explicit Array(int size = DefaultArraySize);
Array(Type *array, int array_size);
Array(const Array &rhs);

virtual ~Array() {delete [] ia;}

bool operator==(const Array &) const;
bool operator!=(const Array &) const;

virtual Type &operator[](int index) {return ia[index];}
virtual void sort();

virtual Type min() const;
virtual Type max() const;
virtual int find(const Type &value) const;

protected:
static const int DefaultArraySize = 12; // <----- problem, compiler says
illegal pure syntax, must be 0.
// Why wont my
compiler let this go?
//My book says
this is ok as long as it's "static const int".

int _size;
Type *ia;
};


Apparently your compiler is old and non-compliant.

V
Jul 23 '05 #2

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:yQ*******************@newsread1.mlpsca01.us.t o.verio.net...
Andy White wrote:
template <class Type>
class Array
{
public:
explicit Array(int size = DefaultArraySize);
Array(Type *array, int array_size);
Array(const Array &rhs);

virtual ~Array() {delete [] ia;}

bool operator==(const Array &) const;
bool operator!=(const Array &) const;

virtual Type &operator[](int index) {return ia[index];}
virtual void sort();

virtual Type min() const;
virtual Type max() const;
virtual int find(const Type &value) const;

protected:
static const int DefaultArraySize = 12; // <----- problem, compiler says illegal pure syntax, must be 0.
// Why wont my compiler let this go?
//My book says this is ok as long as it's "static const int".

int _size;
Type *ia;
};


Apparently your compiler is old and non-compliant.

V


I have vc++ 6.0, I haven't bothered looking into the most up to date
version, what would that be?
Jul 23 '05 #3
Andy White wrote:
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:yQ*******************@newsread1.mlpsca01.us.t o.verio.net...
[...]
Apparently your compiler is old and non-compliant.

V

I have vc++ 6.0, I haven't bothered looking into the most up to date
version, what would that be?


Current release is .NET (or "2003"), which is 7.1 (compiler v 13.1) and
2005, or v8 (compiler v14), is in Beta, last time I looked. The 7.1 is
miles ahead of 6.0, although not free from its quirks.

V
Jul 23 '05 #4
Andy White wrote:
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:yQ*******************@newsread1.mlpsca01.us.t o.verio.net...
Andy White wrote:
template <class Type>
class Array
{
public:
explicit Array(int size = DefaultArraySize);
Array(Type *array, int array_size);
Array(const Array &rhs);

virtual ~Array() {delete [] ia;}

bool operator==(const Array &) const;
bool operator!=(const Array &) const;

virtual Type &operator[](int index) {return ia[index];}
virtual void sort();

virtual Type min() const;
virtual Type max() const;
virtual int find(const Type &value) const;

protected:
static const int DefaultArraySize = 12; // <----- problem, compiler saysillegal pure syntax, must be 0.
// Why wont mycompiler let this go?
//My book saysthis is ok as long as it's "static const int".

int _size;
Type *ia;
};

Apparently your compiler is old and non-compliant.

V


I have vc++ 6.0, I haven't bothered looking into the most up to date
version, what would that be?


Try this free download:

http://lab.msdn.microsoft.com/expres...c/default.aspx

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #5
Andy White wrote:
[redacted]
I have vc++ 6.0, I haven't bothered looking into the most up to date
version, what would that be?


As Victor said, 7.1 (VS.NET 2003) is much better. It's about 98/99%
standards compliant. Also, in addition to the sort of construct you had
there, VC6 is notoriously bad with template code.

I'd highly recommend either 7.1 or a MinGW g++ variant for Windows
programming.

Jul 23 '05 #6
In message <Rd***************@fe02.lga>, Andy White
<br***********@msn.com> writes
template <class Type>
class Array
{
public:
explicit Array(int size = DefaultArraySize);
Array(Type *array, int array_size);
Array(const Array &rhs);

virtual ~Array() {delete [] ia;}
Not that this answers your question, but you'd better declare a copy
assignment operator to make the third in the "rule of three".
bool operator==(const Array &) const;
bool operator!=(const Array &) const;

virtual Type &operator[](int index) {return ia[index];}
virtual void sort();

virtual Type min() const;
virtual Type max() const;
virtual int find(const Type &value) const;

protected:
static const int DefaultArraySize = 12; // <----- problem, compiler says
illegal pure syntax, must be 0.
// Why wont my
compiler let this go?
//My book says
this is ok as long as it's "static const int".

int _size;
Type *ia;
};


--
Richard Herring
Jul 23 '05 #7

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

Similar topics

1
by: Steve | last post by:
I just spent waaaaaaaaaaaayy too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone can explain to me why it was reported that way. ...
1
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
2
by: david | last post by:
Anyone could give me a hand about this syntax error? Thank you. David Source Code: Dim conn As New SqlConnection(strConn) Dim daAngio As New SqlDataAdapter(strSelectStatement, conn) 'Create a...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
1
by: Hari Sekhon | last post by:
I've written an except hook into a script as shown below which works well for the most part and catches exceptions. import sys def myexcepthook(type,value,tb): do something ...
7
by: Josh | last post by:
I have a lot of except Exception, e statements in my code, which poses some problems. One of the biggest is whenever I refactor even the triviallest thing in my code. I would like python to...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
6
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
5
Banfa
by: Banfa | last post by:
So I have a little problem, I have a template class and that class contains a template function; now what I want to do is declare that function in the class (or indeed the entire class) as a friend...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.