dev-cpp-users Mailing List for Dev-C++ (Page 3)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
1
(8) |
2
(14) |
3
(7) |
4
(23) |
5
(6) |
6
(1) |
|
7
(5) |
8
(4) |
9
(1) |
10
(9) |
11
(23) |
12
(28) |
13
(21) |
|
14
(1) |
15
(6) |
16
(2) |
17
(8) |
18
(11) |
19
(17) |
20
(11) |
|
21
(12) |
22
(17) |
23
(7) |
24
(5) |
25
(7) |
26
(4) |
27
(9) |
|
28
(13) |
29
(31) |
30
(9) |
31
(7) |
|
|
|
|
From: stephane w. <ste...@9o...> - 2003-12-28 22:51:47
|
In the Compiler option, I must add "D:/Program = Files/MPICH/SDK/Lib/mpich.lib" to the linker command line to use MPI. But when I close and re-open Dev-C++, the command line is translated as=20 D:/Program Files/MPICH/SDK/Lib/mpich.lib without "". The compiler understand this as 2 phrases like this : D:/Program and = Files/MPICH/SDK/Lib/mpich.lib. How i can solve this problem ? Thank. |
|
From: Maya <Esc...@ne...> - 2003-12-28 21:09:33
|
I am having problems with the inserters and extractors in a template,
can someone help, thanks a bunch!
#ifndef JME_INDEX_H
#define JME_INDEX_H
#include <iostream>
namespace jme{
/*
See:
http://new-brunswick.net/workshop/c++/faq/containers-and-templates.html#faq-34.15
for more information regarding the next pre-declarations
*/
// pre-declare the template class itself
template<typename K, typename D> class Index;
// convince the compiler that the operator<< function is a template
template<typename K, typename D> std::ostream& jme::operator<<
(std::ostream& os, const Index<K,D>& obj);
// convince the compiler that the operator<< functions is a template
template<typename K, typename D> std::istream& jme::operator>>
(std::istream& is, Index<K,D>& obj);
template<typename K, typename D> class Index{
private:
std::string version; // class version
K Key;
D Data;
public:
Index(K const& kx, D const& dx): Key(kx), Data(dx){ }
//Copy C'tor
Index(const jme::Index<K, D>& rhs): Key(rhs->Key),
Data(this->Data){}
const K& getKey() const { return Key;}
const D& getData() const { return Data;}
template<typename K, typename D>
friend std::ostream& jme::operator<< (std::ostream& os,
const Index<K,D>& obj){
return os << obj.getKey << " " << obj.getData();
}
template<typename K, typename D>
friend std::istream& jme::operator>> (std::istream& is,
Index<K,D>& obj){
is >> obj.Key;
is >> obj.Data;
return is;
}
}; //Index
} // jme
#endif
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
|
|
From: Damien A <g_...@ho...> - 2003-12-28 20:37:28
|
<html><div style='background-color:'><DIV class=RTE>
<P><BR><BR></P></DIV>
<DIV></DIV>>From: Maya <ESC...@NE...>
<DIV></DIV>>To: Dev-C++ Mailing List <DEV...@LI...>
<DIV></DIV>>Subject: [Dev-C++] MingWin or Cygwin
<DIV></DIV>>Date: Sun, 28 Dec 2003 15:02:50 -0800
<DIV></DIV><mailto:dev...@li...?subject=unsubscribe><mailto:dev...@li...><mailto:dev...@li...?subject=help><mailto:dev...@li...?subject=subscribe>
<DIV></DIV>
<P>>I am developing a program that gets compiled under two platformes, </P>
<DIV></DIV>>Linux and Windows. In MSW I use Dev-Cpp, which in turn uses MingWin,
<DIV></DIV>>a minimal GCC, but in Linux I use GCC; which is the complete version
<DIV></DIV>>of GCC. Now my problems is that there are certain C functions that
<DIV></DIV>>are incompatible with the two versions of the GCC package, one of
<DIV></DIV>>them is 'mkdir'. In MingWin the declaration is ' int mkdir(const
<DIV></DIV>>char*)' but in UNIX it is 'int mkdir(const char* , int). What can I
<DIV></DIV>>do to let know the compiler that if it is MingWin it should use one
<DIV></DIV>>incarnation of the function and visa versa?
<DIV></DIV>>Example:
<DIV></DIV>>#ifdef MINGWIN
<DIV></DIV>>... use mkdir("file.dat")
<DIV></DIV>>#endif
<DIV></DIV>>#ifdef CYWIN
<DIV></DIV>>... use mkdir("file.data", 0);
<DIV></DIV>>#endif
<DIV></DIV>>#ifdef __GCC__
<DIV></DIV>>...etc., etc.
<DIV></DIV>>#endif
<DIV></DIV>
<DIV>
<P>Hopefully, there aren't many functions you will have to do that with, but you can try something like this:</P></DIV>
<P>#ifdef WIN32</P>
<P>/*Meaning we are in Windows, mingwin, etc. */</P>
<P>#define MAKEDIR(X) mkdir(x)</P>
<P>#else</P>
<P>/*We are in Linux*/</P>
<P>#define MAKEDIR(X) mkdir(x,0)</P>
<P>#endif</mailto:dev...@li...?subject=subscribe></mailto:dev...@li...?subject=help></mailto:dev...@li...></mailto:dev...@li...?subject=unsubscribe></P>
<P>And, just use the macro in those specific cases. Or, you probably could use cygwin, and write the programs as though you were in Linux, just that you need to distribute it with the cygwin dll. Hope that helps.</P></div><br clear=all><hr>Add photos to your messages with <a href="http://g.msn.com/8HMBEN/2749??PS=">MSN 8. </a> Get 2 months FREE*.</html>
|
|
From: Dirk T. <d.t...@gm...> - 2003-12-28 20:09:03
|
> Dev-cpp-users -- confirmation of subscription -- request 760458 |
|
From: Maya <Esc...@ne...> - 2003-12-28 19:54:53
|
I am developing a program that gets compiled under two platformes, Linux
and Windows. In MSW I use Dev-Cpp, which in turn uses MingWin, a minimal
GCC, but in Linux I use GCC; which is the complete version of GCC. Now
my problems is that there are certain C functions that are incompatible
with the two versions of the GCC package, one of them is 'mkdir'. In
MingWin the declaration is ' int mkdir(const char*)' but in UNIX it is
'int mkdir(const char* , int). What can I do to let know the compiler
that if it is MingWin it should use one incarnation of the function and
visa versa?
Example:
#ifdef MINGWIN
... use mkdir("file.dat")
#endif
#ifdef CYWIN
... use mkdir("file.data", 0);
#endif
#ifdef __GCC__
...etc., etc.
#endif
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
|
|
From: Abdelkader G. <go...@li...> - 2003-12-28 17:21:00
|
it's just a small problem with the type that you have declared:
> typedef jme::Index<const int, const std::string > T_index;
So, T_index now is considered as an alias to the type jme::Index<const int,
const std::string >
Consequently, accessing an attribute or a method that are not declared as
static for this class has no sense. Perhaps you intention was to declare a
variable which is an instance of T_index. In this case you should write
this:
<old code> T_index( i, name );
<correct code> T_index my_instance(i,name);
^^^^^^^^^^^
and change also this:
<old code> std::cout << T_index.getKey() << std::endl;
<correct code> std::cout << my_instance.getKey() << std::endl;
^^^^^^^^^^^
Kind regards,
> Can someone please lend me a hand with this, I get the concept of a
> template, but the dynamics are a bit complicated for me, can someone
> please tell me why I get an error saying:
> main.C: In function int main()
> main.C:15:error: parse error before '.' token
>
>
> Thanks
> ---------- index.C -----------
> #ifndef JME_INDEX_H
> #include "index.H"
> #endif
> ------------ index.H ------------
> #ifndef JME_INDEX_H
> #define JME_INDEX_H
>
> template<typename K, typename D>
> class Index{
> private:
> K Key;
> D Data;
>
> public:
> // C'tor
> Index(K const& kx, D const& dx): Key(kx), Data(dx){ }
> K const& getKey() const { return Key;}
> }; //Index
> } // jme
>
> #endif
>
> ---------- main.C -----------
> #include <string>
> #include <iostream>
> #include "index.H"
> int main(){
> const int i = 50;
> const std::string name( "Maya" );
> typedef jme::Index<const int, const std::string > T_index;
> T_index( i, name );
>
> ////<<--- This is the probme //////
> std::cout << T_index.getKey() << std::endl;
> ////<<--- This is the probme /////
>
>
> std::cout << "End of Index..." << std::endl;
> return 0;
> }
> --
>
> FYI
> http://www.astro.umd.edu/~marshall/abbrev.html
>
> E-Mail Policy
> http://www.vif.com/users/escalante/Email_Policy.html
>
> * You cannot exercise your power to a point of humiliation.
> - Jean Chretien
>
> * The media's the most powerful entity on earth. They have the
> power to make the innocent guilty and to make the guilty
> innocent, and that's power.
> - Malcom X
> * "Innocent until proven guilty", no... not in Canada!!
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for
> IBM's Free Linux Tutorials. Learn everything from the bash shell to
> sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Maya <Esc...@ne...> - 2003-12-28 14:11:26
|
Can someone please lend me a hand with this, I get the concept of a
template, but the dynamics are a bit complicated for me, can someone
please tell me why I get an error saying:
main.C: In function int main()
main.C:15:error: parse error before '.' token
Thanks
---------- index.C -----------
#ifndef JME_INDEX_H
#include "index.H"
#endif
------------ index.H ------------
#ifndef JME_INDEX_H
#define JME_INDEX_H
template<typename K, typename D>
class Index{
private:
K Key;
D Data;
public:
// C'tor
Index(K const& kx, D const& dx): Key(kx), Data(dx){ }
K const& getKey() const { return Key;}
}; //Index
} // jme
#endif
---------- main.C -----------
#include <string>
#include <iostream>
#include "index.H"
int main(){
const int i = 50;
const std::string name( "Maya" );
typedef jme::Index<const int, const std::string > T_index;
T_index( i, name );
////<<--- This is the probme //////
std::cout << T_index.getKey() << std::endl;
////<<--- This is the probme /////
std::cout << "End of Index..." << std::endl;
return 0;
}
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
|
|
From: Abdelkader G. <go...@li...> - 2003-12-28 13:40:08
|
Hi there,
Your code is well written, it should compile and run, just check that you
have compiled correctly the 'file.C' (rename it to .cpp :) or delete all
old *.o files and recompile all the project.
Kind regards,
> This is my first 'class template', so I am sure I am doing something
> wrong. Can anyone help?
>
> TIA
> ------ file.H ------
> namespace jme{
> template<class K, class D>
> class Index{
> protected:
> K Key;
> D Data;
>
> public:
> // C'tor
> Index(K kx, D dx);
> ~Index();
> };
> }
> ------ file.C ------
> template<class K, class D>
> jme::Index<K,D>::Index(K kx, D dx){
> Key = kx;
> Data = dx;
> }
> template<class K, class D>
> jme::Index<K,D>::~Index(){ }
> ------ main.C ------
> int main(){
> int i = 50;
> std::string name("Maya");
> jme::Index<int, std::string> ndx(i,name);
> return 0;
> }
> ------ Error message ------
> main.o(.text+0xb9):main.C: undefined reference to `jme::Index<int,
> std::string>::Index(int, std::string)'
> main.o(.text+0x12c):main.C: undefined reference to `jme::Index<int,
> std::string>::~Index()'
> main.o(.text+0x152):main.C: undefined reference to `jme::Index<int,
> std::string>::~Index()'
> --
>
> FYI
> http://www.astro.umd.edu/~marshall/abbrev.html
>
> E-Mail Policy
> http://www.vif.com/users/escalante/Email_Policy.html
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for
> IBM's Free Linux Tutorials. Learn everything from the bash shell to
> sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Kevin B. <tec...@ne...> - 2003-12-28 06:54:58
|
Operators may not be overloaded for built-in types, for reasons that are fairly clear if you pause to consider the implications. In this case, you are attempting to fundamentally change the meaning of the expression. You might think of char* as a "string", but C++ thinks of it as a pointer. s1 == s2 compares the address values contained in the pointer itself, not the strings they point to. You are asking it for a radical change in behavior. Consider the potential for mischief allowing this sort of thing would cause. C++ already has enough minefields. The whole point of operator overloading is to make the resulting code more clear in its intent. Your attempt not only obfuscates the resulting code, since you are actually attempting to compare not the pointers but the null-terminated char arrays they reference, and furthermore lays a booby-trap for anybody hoping to maintain the code thereafter who foolishly assumes they can tell if two variables are pointing to the same location by using the == operator. And so, such things are illegal. It is allowed for custom types, since there are no preexisting assumptions about how such types should behave as there would be with, say, int or bool. Even so, operator overloading used to excess can quickly make code practically unmaintainable. You need to use a string class with the (char *) and == operators overloaded in the way you desire. The standard library already provides such a class, std::String. You can do exactly what you want with no further coding required like so: String( s1) == String( s2 ). Of course, using String to hold your strings in the first place would eliminate a lot of temporaries. I question what you would be accomplishing by the foregoing maneuver. Or, you could make your own lightweight struct with the necessary operators and constructors. But honestly, if you can't or don't want to use std::String from the start, is reading strcmp really so bad? Why confuse the situation and introduce potential bugs and maintenance headaches just so you can use == and save a few keystrokes? If the use of a real string class is unpalatable, I strongly suggest sticking with the strcmp method, since anybody reading it will most certainly understand what is going on, whereas your attempts at operator magic will likely just confuse the situation. Refactor when it produces a measurable benefit, not just because you can. If you must refactor this code, refactor to use std::String instead of char* altogether, rather than just worrying about the compare operation. --- Kevin |
|
From: Maya <Esc...@ne...> - 2003-12-28 05:21:59
|
This is my first 'class template', so I am sure I am doing something
wrong. Can anyone help?
TIA
------ file.H ------
namespace jme{
template<class K, class D>
class Index{
protected:
K Key;
D Data;
public:
// C'tor
Index(K kx, D dx);
~Index();
};
}
------ file.C ------
template<class K, class D>
jme::Index<K,D>::Index(K kx, D dx){
Key = kx;
Data = dx;
}
template<class K, class D>
jme::Index<K,D>::~Index(){ }
------ main.C ------
int main(){
int i = 50;
std::string name("Maya");
jme::Index<int, std::string> ndx(i,name);
return 0;
}
------ Error message ------
main.o(.text+0xb9):main.C: undefined reference to `jme::Index<int,
std::string>::Index(int, std::string)'
main.o(.text+0x12c):main.C: undefined reference to `jme::Index<int,
std::string>::~Index()'
main.o(.text+0x152):main.C: undefined reference to `jme::Index<int,
std::string>::~Index()'
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
|
|
From: Tom C. <jat...@gm...> - 2003-12-27 18:10:12
|
Are you running an anti-virus program? I had to disable Norton when compiling or the entire system would crash. I've since changed to McAfee and have to disable that too, or my floppy drive is repeatedly scanned for a disk. I too am using WinME. --Tom ----- Original Message ----- From: "Russell Schiwal" <rsc...@ya...> To: <dev...@li...> Sent: Thursday, December 25, 2003 9:23 AM Subject: [Dev-C++] MAJOR bug > I have repeatedly downloaded the new beta version of Dev-cpp and have yet you be able to complete a compile. Every time I try to compile my entire system fails, and it is always at the same time: less than one second after I hit the compile command. > I have even gone as far as substituting the old compiler, g++, gcc, make, etc files to see if that would help, but to no avail. > I am running an AMD Duron 750 MHZ with Windows ME and over 500 megs of ram. > Version 4 wasn't perfect, but it worked fine. > Please help. > Sincerely, > Russell Schiwal > > > --------------------------------- > Do you Yahoo!? > Yahoo! Photos - Get your photo on the big screen in Times Square |
|
From: Abdelkader G. <go...@li...> - 2003-12-27 17:36:50
|
To have the code presented above compiling, you should try this:
--------------------------------------------------------------
#include <iostream>
#include <stdlib.h>
using namespace std;
//encapsulate the int type inside a
//structure
typedef struct
{
const int value;
} _int;
//the operator is now defined
//for the structure _int
bool operator==(const _int i,const _int j)
{
cout << "hello" <<endl;
return (i.value + j.value);
}
int main(int argc, char *argv[])
{
_int i = {1};
_int j = {-1};
cout << (i == j) <<endl;
return 0;
}
---------------------------------------------------
The output is:
hello
0
kind regards,
> hi there,
>
> Are you sure that you can overload operator for simple types that are
> not classes? You can emulate built in types operators for you
> defined 'classes', but I'm not sure that you can redefine operator for
> built in types and if this is allowed what a catastrophy it would be ,)
> imagine this (bogus) code:
>
> bool operator==(const int i,const int j)
> {
> return (bool) (i + j);
> }
> //this code change the semantics of ==
> // 4 == -4 -> true 4 == 4 ->false
>
> If you are allowed to change the definition of the == (int equals) this
> means that this operator is changed for 'all' int == operation, so can
> you imagine what happends if you include others source code that have
> used another semantics for the (int ==).
>
> So, I'm not sure that you can overload built in types but if you have
> more information I'm interested ,)
>
> Kind regards;
>
>> Ok here is my dilema.
>>
>> Scattered throught my code is the following line:
>>
>> if(!strcmp(var1,var2))
>> ....
>>
>> What would be the best way to change that to
>>
>> if( var1 == var2 )
>> ....
>>
>> So far here is some exaple code that illustrates my problem:
>> bool operator==(char *s1, char *s2)
>> {
>> if(!strcmp(s1,s2))
>> return true;
>> else
>> return false;
>> }
>>
>> int main()
>> {
>> char x[10] = "Hello";
>> char y[10] = "Hello";
>> if(x == y)
>> cout << "Equal" << endl;
>> else
>> cout << "Not equal" << endl;
>> cin.get();
>> return 0;
>> }
>>
>> Error:
>> C:/Documents and Settings/David/My Documents/scratch.cpp:9: `bool
>> operator==(char*, char*)' must have an argument of class or
>> enumerated type
>>
>> What does it mean?? I have done operator overloading with various
>> classes but I can't get it to work with char *, please help. There is
>> no one to make it a friend with so that is ruled out.
>>
>> =====
>> Signed
>> David Mcken
>>
>> Life Sucks
>> Live with it
>>
>> __________________________________
>> Do you Yahoo!?
>> New Yahoo! Photos - easier uploading and sharing.
>> http://photos.yahoo.com/
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: IBM Linux Tutorials.
>> Become an expert in LINUX or just sharpen your skills. Sign up for
>> IBM's Free Linux Tutorials. Learn everything from the bash shell to
>> sys admin. Click now!
>> http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
>> _______________________________________________
>> Dev-cpp-users mailing list
>> Dev...@li...
>> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for
> IBM's Free Linux Tutorials. Learn everything from the bash shell to
> sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Abdelkader G. <go...@li...> - 2003-12-27 17:13:40
|
hi there,
Are you sure that you can overload operator for simple types that are not
classes? You can emulate built in types operators for you
defined 'classes', but I'm not sure that you can redefine operator for
built in types and if this is allowed what a catastrophy it would be ,)
imagine this (bogus) code:
bool operator==(const int i,const int j)
{
return (bool) (i + j);
}
//this code change the semantics of ==
// 4 == -4 -> true 4 == 4 ->false
If you are allowed to change the definition of the == (int equals) this
means that this operator is changed for 'all' int == operation, so can you
imagine what happends if you include others source code that have used
another semantics for the (int ==).
So, I'm not sure that you can overload built in types but if you have more
information I'm interested ,)
Kind regards;
> Ok here is my dilema.
>
> Scattered throught my code is the following line:
>
> if(!strcmp(var1,var2))
> ....
>
> What would be the best way to change that to
>
> if( var1 == var2 )
> ....
>
> So far here is some exaple code that illustrates my problem:
> bool operator==(char *s1, char *s2)
> {
> if(!strcmp(s1,s2))
> return true;
> else
> return false;
> }
>
> int main()
> {
> char x[10] = "Hello";
> char y[10] = "Hello";
> if(x == y)
> cout << "Equal" << endl;
> else
> cout << "Not equal" << endl;
> cin.get();
> return 0;
> }
>
> Error:
> C:/Documents and Settings/David/My Documents/scratch.cpp:9: `bool
> operator==(char*, char*)' must have an argument of class or
> enumerated type
>
> What does it mean?? I have done operator overloading with various
> classes but I can't get it to work with char *, please help. There is
> no one to make it a friend with so that is ruled out.
>
> =====
> Signed
> David Mcken
>
> Life Sucks
> Live with it
>
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for
> IBM's Free Linux Tutorials. Learn everything from the bash shell to
> sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Damien A <g_...@ho...> - 2003-12-27 16:48:07
|
<html><div style='background-color:'><DIV class=RTE>
<P><BR></P>
<P>You could change your code to use C++ strings instead of char*. That way, you
<DIV>wouldn't have to write your own == function, as it is one of the methods of the C++ string class. </DIV>
<DIV> </DIV>
<DIV>#include <iostream><BR>#include <string><BR>using namespace std;<BR>int main()<BR>{ <BR> string x = "Hello";<BR> string y = "Hello";<BR> if(x == y)<BR> cout << "Equal" << endl;<BR> else<BR> cout << "Not equal" << endl;<BR> cin.get();<BR> return 0;<BR>}</DIV>
<P></P>
<P><BR></P></DIV>
<DIV></DIV>>From: David McKen <CI...@YA...>
<DIV></DIV>>Reply-To: ci...@ya...
<DIV></DIV>>To: Dev-C Mailing List <DEV...@LI...>
<DIV></DIV>>Subject: [Dev-C++] Operator overloading for built in types.
<DIV></DIV>>Date: Sat, 27 Dec 2003 06:37:31 -0800 (PST)
<DIV></DIV><mailto:dev...@li...?subject=unsubscribe><mailto:dev...@li...><mailto:dev...@li...?subject=help><mailto:dev...@li...?subject=subscribe>
<DIV></DIV>>
<DIV></DIV>>Ok here is my dilema.
<DIV></DIV>>
<DIV></DIV>>Scattered throught my code is the following line:
<DIV></DIV>>
<DIV></DIV>>if(!strcmp(var1,var2))
<DIV></DIV>>....
<DIV></DIV>>
<DIV></DIV>>What would be the best way to change that to
<DIV></DIV>>
<DIV></DIV>>if( var1 == var2 )
<DIV></DIV>>....
<DIV></DIV>
<P>
<DIV> </DIV></P></mailto:dev...@li...?subject=subscribe></mailto:dev...@li...?subject=help></mailto:dev...@li...></mailto:dev...@li...?subject=unsubscribe></div><br clear=all><hr>Add photos to your messages with <a href="http://g.msn.com/8HMAEN/2749??PS=">MSN 8. </a> Get 2 months FREE*.</html>
|
|
From: Kurt W. <km...@ro...> - 2003-12-27 16:44:51
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of David > McKen > Sent: Saturday, December 27, 2003 8:38 AM > To: Dev-C Mailing List > Subject: [Dev-C++] Operator overloading for built in types. > > > Ok here is my dilema. > > Scattered throught my code is the following line: > > if(!strcmp(var1,var2)) Not to be a dick, but why are you using char arrays as strings in C++ anyway? Kurt Weber |
|
From: David M. <ci...@ya...> - 2003-12-27 14:37:37
|
Ok here is my dilema.
Scattered throught my code is the following line:
if(!strcmp(var1,var2))
....
What would be the best way to change that to
if( var1 == var2 )
....
So far here is some exaple code that illustrates my problem:
bool operator==(char *s1, char *s2)
{
if(!strcmp(s1,s2))
return true;
else
return false;
}
int main()
{
char x[10] = "Hello";
char y[10] = "Hello";
if(x == y)
cout << "Equal" << endl;
else
cout << "Not equal" << endl;
cin.get();
return 0;
}
Error:
C:/Documents and Settings/David/My Documents/scratch.cpp:9: `bool
operator==(char*, char*)' must have an argument of class or
enumerated type
What does it mean?? I have done operator overloading with various
classes but I can't get it to work with char *, please help. There is
no one to make it a friend with so that is ruled out.
=====
Signed
David Mcken
Life Sucks
Live with it
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
|
|
From: Kurt W. <km...@ro...> - 2003-12-27 08:24:56
|
Using Dev-C++ 4.9.8.5, compiliation does not result in error messages being displayed to the error-message area at the bottom of the screen. I know error messages should be there because I get them when I compile from the command line, but for some reason they are not appearing at the bottom of the Dev-C++ window. Kurt Weber |
|
From: Michael C U. <mu...@cb...> - 2003-12-27 02:12:09
|
On Sat, 27 Dec 2003, [ISO-8859-1] OROSZI Bal=E1zs wrote: > Because then the variables will be inside the CASE, not in the SWITCH, > and they only get allocated, if that specific CASE is selected, not > every time the program enters the SWITCH. Ah. Ok. I see now. I thought the compiler would just ignore it because if CASE was false, the statements inside that case statement wouldn't even be evaluated. But, yes. I see what happens now. It won't even compile without the braces if they are declarations inside the case. > > -- > Greetings, > Bal=E1zs > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: <or...@vp...> - 2003-12-27 00:43:21
|
Michael C Urban wrote:
>>And about that { } braces inside the case: it is needed because
>>variables are declared inside the case, and they need to be kept in the
>>scope of the case statement, and that can only be achieved by creating a
>>block inside it.
>
>
> But the variables will go out of scope when the break or return statement
> is encountered won't they? Because the entire select block is enclosed in
> braces, so they variables will be local to the select block. Once the
> select block has exited, the variables should go out of scope shouldn't
> they?
>
> So given that, I don't see why the braces are necessary enclosing the
> case.
Because then the variables will be inside the CASE, not in the SWITCH,
and they only get allocated, if that specific CASE is selected, not
every time the program enters the SWITCH.
--
Greetings,
Balázs
|
|
From: Michael C U. <mu...@cb...> - 2003-12-26 21:25:20
|
> And about that { } braces inside the case: it is needed because
> variables are declared inside the case, and they need to be kept in the
> scope of the case statement, and that can only be achieved by creating a
> block inside it.
But the variables will go out of scope when the break or return statement
is encountered won't they? Because the entire select block is enclosed in
braces, so they variables will be local to the select block. Once the
select block has exited, the variables should go out of scope shouldn't
they?
So given that, I don't see why the braces are necessary enclosing the
case.
|
|
From: Hossein H. <ult...@em...> - 2003-12-26 18:43:11
|
Hi Maya,
Sorry if a little bit late!
> Can someone please help me?
> I am using an enum type that I want to store in a std::IOStream object,
> but the compiler [complainer] tells me that the format is not supported.
> enum types are the same as 'const int' right?
Nope! They are not. I checked the Standard and found out that,
in Section 7.2 (Enumeration Decleration) #5, it says that the
underlying type of an enumeration is an integeral type that is
implementation-specific. It doesn't mention anything about
whether it is a const-qualified type or not. Nor does it mention
anything about whether there must be just one candidate
underlying type for a given enum type or are two or more
candidates possible as well.
> namespace jme{
> enum account_t {Zero, One, Two};
> class Account{
> protected:
> account_t type;
>
> ....
> public:
> friend std::istream&
> jme::operator>>(std::istream& is, jme::Account& obj){
> is >> obj.type; // <<======== Here is the problem ****
> return is;
> }
> };
> }
> This gives me an error that reads:
> ====================================================
> account.H: In function `std::istream& jme::operator>>(std::istream&,
> jme::Account&)':
> account.H:91: no match for `std::basic_istream<char,
> std::char_traits<char> >&
> >> jme::account_t&' operator <<<<<<<====== This is the problem *****
> ...: candidates are:
>
> /* Gives me a list of other candidates */
>
> ====================================================
Considering the above citations from the Standard, it seems that
your compiler has found itself not knowing which type to choose
as the underlying type. I think the best solution is to choose
one and clarify it in a way that the compiler understands it.
Furthermore, that long error comment from your compiler is just
'cause it's trying to use the default streaming tools.
Regards,
--Hossein
--
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
|
|
From: Maya <Esc...@ne...> - 2003-12-26 14:52:52
|
namespace Merry{
class Christmas{
public:
// This line is fine!
static const std::ios_base::openmode To_all = std::ios_base::in;
// The below line triggers an error ?
static const std::ios_base::openmode To_Ya =
std::ios_base::out | std::ios_base::app;
protected:
///Bla, bla, bla
};
}
Gives me the following error:
finelname:line: field initializer is not constant
Why is it that 'Merry::Christmas::To_all' is a prblem for the compiler,
but 'Merry::Christmas::To_Ya' is otherwise?
Anybody?
By the way, what I want is to have access to those variables from
another program, using the scope specifiers, will that do the trick?
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
|
|
From: <age...@co...> - 2003-12-26 01:46:58
|
Obviously, tell people not to use poor footers. If your ISP e-mail client has signatures, use them. Comcast provides signatures which do the same thing. The Scott Simontis, Programmer thing at the bottom is a signature. And, I can store 3. However, when people try to use HTML in messages (a wonderful thing gone terribly wrong.) Also, some third-party mail apps might have problems. -- ~~Scott Simontis~~ Programmer > Hi > I've been getting many emails from the group in recent months which arrive > empty, my IT dept has tried to find out the cause since they seem to get to > the group host site OK & I have had the following response: > > > -----Original Message----- > From: SurfControl UK/EMEA Tech Support (CO) [mailto:su...@Su...] > > Sent: 19 December 2003 16:48 > To: 'Jason Walker' > Subject: RE: empty emails > > Hi Jason, > > We have been investigating the issue that you have reported regarding the > message body being removed by the email filter. This issue is being caused > because the footer that is being applied to the message by the sender. The > footer is outside the defined boundaries of the message, this causes the > email filter to enclose the footer within the last boundary thus when the > message is viewed it reads the footer as the message body. Would it be > possible to ask the sender not to apply the footer or to enclose the footer > in the message body and not outside the boundary? > > Regards, > Ian > > -------------------- > > > > Has anyone else had problems of the same sort or know a fix ? > Best regards & seasonal greeting to all. > Mark > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.552 / Virus Database: 344 - Release Date: 15/12/2003 > > > > The information contained in this e-mail message (and any attachment > transmitted herewith) is privileged and confidential and is intended for the > exclusive use of the addressee(s). If you are not an addressee, any > disclosure, reproduction, distribution or other dissemination or use of this > communication is strictly prohibited. If you have received this > communication in error, please contact us immediately so that we can correct > the error. > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Damien A <g_...@ho...> - 2003-12-25 21:02:32
|
<html><div style='background-color:'><DIV class=RTE>
<P><BR><BR></P></DIV>
<DIV></DIV>>From: "Noorez Kassam" <COO...@HO...>
<DIV></DIV>>To: dev...@li...
<DIV></DIV>>Subject: [Dev-C++] WinAPP
<DIV></DIV>>Date: Wed, 24 Dec 2003 14:11:53 -0700
<DIV></DIV>
<P>>MIME-Version: 1.0 </P>
<P> </P>
<DIV></DIV><mailto:dev...@li...?subject=unsubscribe><mailto:dev...@li...><mailto:dev...@li...?subject=help><mailto:dev...@li...?subject=subscribe>
<DIV></DIV>>My windows APP is closing before i see any results! It complies fine
<DIV></DIV>>but it just closes
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>> WNDCLASSEX wndClass;
<DIV></DIV>>
<DIV></DIV>> //register class
<DIV></DIV>> wndClass.style = 0;
<DIV></DIV>> wndClass.lpfnWndProc = WindowProc;
<DIV></DIV>> wndClass. cbClsExtra = 0;
<DIV></DIV>> wndClass.hInstance = hInstance;
<DIV></DIV>> wndClass.hIcon = LoadIcon( hInstance, szAppName);
<DIV></DIV>> wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
<DIV></DIV>> wndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
<DIV></DIV>> wndClass.lpszMenuName = NULL;
<DIV></DIV>> wndClass.lpszClassName = szAppName;
<DIV></DIV>> wndClass.hIconSm = wndClass.hIcon;
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>
<P>Hmm, do you have a resource file that actually has the specified icon? But anyways, the reason your app fails is because RegisterClassEx returns 0. The reason for this prolly were: cbWndExtra was not initialized, and more importantly: cbSize was not initialized/set to the size of the WNDCLASSEX structure. </P>
<P>I changed your code to this:</P>
<P>WNDCLASSEX wndClass = {0}; </P>
<P>//register class <BR>wndClass.style = CS_OWNDC; // A habit I picked up from OpenGL<BR>wndClass.lpfnWndProc = WindowProc; </P>
<P>wndClass.hInstance = hInstance; <BR>wndClass.hIcon = LoadIcon( NULL, IDI_WINLOGO); //A standard windows icon<BR>wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); <BR>wndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND; <BR>wndClass.lpszMenuName = NULL; <BR>wndClass.lpszClassName = szAppName; <BR>wndClass.hIconSm = wndClass.hIcon; <BR>wndClass.cbSize = sizeof(WNDCLASSEX); //Important field</P>
<P>and it worked ;).</P>
<P>>_________________________________________________________________ </P>
<DIV></DIV>>MSN 8 with e-mail virus protection service: 2 months FREE*
<DIV></DIV>>http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=https%3a%2f%2f2.zoppoz.workers.dev%3a443%2fhttp%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>-------------------------------------------------------
<DIV></DIV>>This SF.net email is sponsored by: IBM Linux Tutorials.
<DIV></DIV>>Become an expert in LINUX or just sharpen your skills. Sign up for
<DIV></DIV>>IBM's
<DIV></DIV>>Free Linux Tutorials. Learn everything from the bash shell to sys
<DIV></DIV>>admin.
<DIV></DIV>>Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
<DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></mailto:dev...@li...?subject=subscribe></mailto:dev...@li...?subject=help></mailto:dev...@li...></mailto:dev...@li...?subject=unsubscribe></div><br clear=all><hr>MSN 8 helps <a href="http://g.msn.com/8HMAEN/2752??PS=">ELIMINATE E-MAIL VIRUSES.</a> Get 2 months FREE*.</html>
|
|
From: <or...@vp...> - 2003-12-25 21:01:17
|
Hi!
You left out 2 members of your wndclass structure.
wndClass.cbWndExtra = 0;
wndClass.cbSize = sizeof(WNDCLASSEX);
And about that { } braces inside the case: it is needed because
variables are declared inside the case, and they need to be kept in the
scope of the case statement, and that can only be achieved by creating a
block inside it.
--
Greetings,
Balázs
|