473,378 Members | 1,416 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.

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 4665
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: 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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...

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.