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

BEFORE I EXPLODE

G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I'm writing a program at the moment and I have to finish it
real soon. The problem I'm having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!

Some enlightenment please,

-JKop
Jul 22 '05 #1
17 2673
JKop wrote:
G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I'm writing a program at the moment and I have to finish it
real soon. The problem I'm having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!

Some enlightenment please,

operator const int()

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #2
Ioannis Vranos posted:
JKop wrote:
G++ gives the most un-informative, cryptic, BULLSHIT errors statements.

I'm writing a program at the moment and I have to finish it real soon. The problem I'm having is illustrated in the following:
class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!

Some enlightenment please,

operator const int()

That was my first thought.

The bleeding thing still doesn't work!

The words "compiler bug" are coming to mind...

Anyway,

the operator int() returns by *value*, so it would make no
difference whatsoever if the object was const or not.

The only reason I can see of being able to define both:

operator int()

and

operator const int()

is to have separate routines that work differently on const
objects Vs normal objects.

I could have the program written five times already if I
didn't have to deal with this bullshit.

Right now, I'm getting around it via:

Blah temp(poo);

switch (temp)
That's until I figure out what the hell's going on!
-JKop

-JKop
Jul 22 '05 #3
JKop wrote:
G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I'm writing a program at the moment and I have to finish it
real soon. The problem I'm having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()

// Means it doesn't modify k
operator int() const
// Also a default constructor is needed

{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!

Some enlightenment please,

-JKop


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #4
* JKop:

[swear words]


The problem is trivial and the posting excessive: stop trolling.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #5
Ioannis Vranos posted:
operator int() const

This is me shaking your virtual hand:

*shakes virtual hand*

Hallileujah (or however you spell it!)
Thanks a lot Ioannis.
-JKop
Jul 22 '05 #6
Alf P. Steinbach posted:
* JKop:

[swear words]
The problem is trivial and the posting excessive: stop

trolling.


Subjective, asshole.
-JKop
Jul 22 '05 #7
In article <AC*******************@news.indigo.ie>,
JKop <NU**@NULL.NULL> wrote:
G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

I'm writing a program at the moment and I have to finish it
real soon. The problem I'm having is illustrated in the
following:

class Blah
{
private:

int k;

public:

operator int()
{
return k;
}

};
int main()
{
Blah const poo;

switch (poo)
{
case 1:
;
}

}
The yokie that goes in a switch statement has to be an
integral type. My class has an "operator int()". Grand.

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!

Some enlightenment please,


Here's the results from Comeau C++ (hint hint) which hopefully helps:

G:\tmp>como --A --vc71 cct.cpp
Comeau C/C++ 4.3.4.1 (May 29 2004 23:08:11) for MS_WINDOWS_x86
Copyright 1988-2004 Comeau Computing. All rights reserved.
MODE:strict errors C++

"cct.cpp", line 20: error: const variable "poo" requires an initializer --
class "Blah" has no explicitly declared default constructor
Blah const poo;
^

"cct.cpp", line 22: error: expression must have integral or enum type
switch (poo)
^

"cct.cpp", line 22: warning: variable "poo" is used before its value is set
switch (poo)
^

2 errors detected in the compilation of "cct.cpp".
--
Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #8
co****@panix.com (Greg Comeau) wrote:
JKop <NU**@NULL.NULL> wrote:
G++ gives the most un-informative, cryptic, BULLSHIT errors
statements.

class Blah
{
int k;
operator int() { return k; }
};

int main()
{
Blah const poo;

switch (poo)

Note that the "poo" object is const. If I make the poo
object non-const, then the above code compiles. BUT WHAT
THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!
Here's the results from Comeau C++ (hint hint) which hopefully helps:


This guy refuses to pay for software on principle, so you'll
be lucky..
"cct.cpp", line 22: error: expression must have integral or enum type
switch (poo)
^

Interestingly, g++'s error message is:
error: passing `const Blah' as `this' argument of
`Blah::operator int()' discards qualifiers

ie. it seems that g++ selected 'operator int' and then noted that
you can't call a non-const function for a const object (which
was the OP's problem). Your compiler seems to have not selected
this function at all for that reason (so IMHO in this
particular case, g++'s error message was more informative).
Comments?
Jul 22 '05 #9
In article <84**************************@posting.google.com >,
Old Wolf <ol*****@inspire.net.nz> wrote:
co****@panix.com (Greg Comeau) wrote:
JKop <NU**@NULL.NULL> wrote:
>G++ gives the most un-informative, cryptic, BULLSHIT errors
>statements.
>
>class Blah
>{
> int k;
> operator int() { return k; }
>};
>
>int main()
>{
> Blah const poo;
>
> switch (poo)
>
>Note that the "poo" object is const. If I make the poo
>object non-const, then the above code compiles. BUT WHAT
>THE HELL DIFFERENCE DOES IT MAKE IF IT'S CONST!


Here's the results from Comeau C++ (hint hint) which hopefully helps:


This guy refuses to pay for software on principle, so you'll
be lucky..
"cct.cpp", line 22: error: expression must have integral or enum type
switch (poo)
^

Interestingly, g++'s error message is:
error: passing `const Blah' as `this' argument of
`Blah::operator int()' discards qualifiers

ie. it seems that g++ selected 'operator int' and then noted that
you can't call a non-const function for a const object (which
was the OP's problem). Your compiler seems to have not selected
this function at all for that reason (so IMHO in this
particular case, g++'s error message was more informative).
Comments?


I'd be confused because it's telling me something about
a function it should not have picked.
--
Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #10
"cct.cpp", line 22: error: expression must have integral or enum type switch (poo) ^

Interestingly, g++'s error message is:
error: passing `const Blah' as `this' argument of
`Blah::operator int()' discards qualifiers

What G++ version is that?! Look at my original post, I got
a totally different, non-informative error.

-JKop
Jul 22 '05 #11
JKop <NU**@NULL.NULL> writes:
"cct.cpp", line 22: error: expression must have integral or enum type switch (poo) ^

Interestingly, g++'s error message is:
error: passing `const Blah' as `this' argument of
`Blah::operator int()' discards qualifiers

What G++ version is that?! Look at my original post, I got
a totally different, non-informative error.


A little question: Do you use 3.4?

Kind regards,
Nicolas

--
| Nicolas Pavlidis | Elvis Presly: |\ |__ |
| Student of SE & KM | "Into the goto" | \|__| |
| pa****@sbox.tugraz.at | ICQ #320057056 | |
|-------------------University of Technology, Graz----------------|
Jul 22 '05 #12
Nicolas Pavlidis posted:
What G++ version is that?! Look at my original post, I got a totally
different, non-informative error.


A little question: Do you use 3.4?

Kind regards,
Nicolas

Okay could you do me a favour please?

Hold my hand and slowly guide me through the process of downloading the
latest version of G++.

I remember the last time I downloaded G++, it was one of the most traumatic
experiences of my life... to this day I still wake up in a cold sweat
thinking of those abbreviations. Cryptic is not the word.
Thanks,

-JKop
Jul 22 '05 #13
JKop wrote:
Nicolas Pavlidis posted:

What G++ version is that?! Look at my original post, I got a totally
different, non-informative error.


A little question: Do you use 3.4?

Kind regards,
Nicolas


Okay could you do me a favour please?

Hold my hand and slowly guide me through the process of downloading the
latest version of G++.

I remember the last time I downloaded G++, it was one of the most traumatic
experiences of my life... to this day I still wake up in a cold sweat
thinking of those abbreviations. Cryptic is not the word.

What GCC are you using, what version and in what OS?
In Windows you may use the latest Beta of Dev-C++ at
http://www.bloodshed.net.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #14
Ioannis Vranos posted:
JKop wrote:
Nicolas Pavlidis posted:

What G++ version is that?! Look at my original post, I got a totallydifferent, non-informative error.

A little question: Do you use 3.4?

Kind regards,
Nicolas
Okay could you do me a favour please?

Hold my hand and slowly guide me through the process of downloading the latest version of G++.

I remember the last time I downloaded G++, it was one of the most traumatic experiences of my life... to this day I still wake up in a cold sweat thinking of those abbreviations. Cryptic is

not the word.

What GCC are you using, what version and in what OS?
In Windows you may use the latest Beta of Dev-C++ at
http://www.bloodshed.net.

I hate bugs, I mean, I hate Dev C++. They've almost become
synonyms for me. When I hear "bugs", I think "Dev C++".
When I think "Dev C++", I think "bugs".

Anyway, I've got the latest version of MS Visual Studio on
its way to me... :-D

A BETA version of Dev C++, is that for the 3rd World?
-JKop
Jul 22 '05 #15
JKop wrote:
A BETA version of Dev C++, is that for the 3rd World?

You may download the latest version of GCC for Windows:
http://prdownloads.sf.net/mingw/MinG...1.exe?download

and use it from command line or use Context:

http://www.context.cx/

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #16
Ioannis Vranos posted:
JKop wrote:
A BETA version of Dev C++, is that for the 3rd World?

You may download the latest version of GCC for Windows:
http://prdownloads.sf.net/mingw/MinGW-3.1.0-1.exe?

download
Beautiful!

and use it from command line or use Context:

http://www.context.cx/

Have been for a while!
-JKop
Jul 22 '05 #17
JKop <NU**@NULL.NULL> wrote:
"cct.cpp", line 22: error: expression must have integral or enum type switch (poo) ^

Interestingly, g++'s error message is:
error: passing `const Blah' as `this' argument of
`Blah::operator int()' discards qualifiers


What G++ version is that?! Look at my original post, I got
a totally different, non-informative error.


You never posted any error messages. This is g++ (note: lower-case
g) 3.4.1. I got it from http://gcc.gnu.org/ . If you want a
Windows binary then you should install Cygwin (www.cygwin.com)
or Mingw.
Jul 22 '05 #18

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

Similar topics

5
by: Rob Gudgeon | last post by:
Hi Is it possible to explode a string into an array using more than one separator? I have database records that contain several values, mostly split by semi-colons but some older records are...
6
by: William Krick | last post by:
I have a string containing concatenated ascii "records" that are each terminated by '\n'. For testing purposes, I construct sample data like this... $mystring =...
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
4
by: Richard Lawrence | last post by:
Hi there, I'm having a problem with PHP which I'm not sure how to best solve. Here is the code: $fp = fopen("comments.txt", "r"); while(!feof($fp)) { $line = fgets($fp, 1024); list($key,...
12
by: frizzle | last post by:
Hi there, i have a site with fake folders & files. htaccess rewrites everything to index.php?vars now in index.php i decide what file to include with a switch/case statement. to define where...
5
by: FFMG | last post by:
Hi, I need the php equivalent of explode in one of my app. I read a very big file and "explode" each line to fill a structure. The reading of the file, 19Mb, (I will also need to streamline...
0
by: k04jg02 | last post by:
Python has a nifty operator that will take a container and pass its elements as function parameters. In Python you can make a list like so: x = Then you can say: f(*x)
4
by: Davide | last post by:
Hi All, I'm trying to use explode to separate the result of a textual file, but it explode me only the first row. the foo.txt is pippo pluto pluto pippo pippo pippo .... I use this script...
8
by: Jack | last post by:
I would like to Explode a string into an array that does not begin at 0 but I can't get it to work. For example: $MyInfo = array(1 =27,68,31,19,40); will result in $MyInfo = 27 ... $MyInfo = 40...
8
by: vinpkl | last post by:
hi all i want to use explode url for shotening my urls i have a url like http://localhost/vineet/products.php?dealer_id=12&category_id=2 This is my navigation php code that has url...
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
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
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...
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.