dev-cpp-users Mailing List for Dev-C++ (Page 609)
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
|
|
From: Daniel W. <d_w...@ho...> - 2002-03-27 00:06:14
|
Hi! Well, maybe you dont have all the things (libraries and such) necessary = to compile a GTK application, but you can find that things in the = homepage of Dev-C++ (www.bloodshed.net), there is a link to "packages" = and there are two packages for GTK, the runtime library and the other = libraries. Well hope i helped Daniel Wilches M. dwi...@ma... |
|
From: Brian P. <br...@su...> - 2002-03-26 23:28:46
|
If you have mysql installed on your machine it should be in that directory somewhere (on my RedHat 7.2 installation it is /usr/include/mysql/mysql.h and on my Windows 2k box it is c:\mysql\include\mysql.h). You will need to tell Dev-C++ where this header file is under the compiler or project options. You will then need to give it the switch: -lmysqlclient under compiler or project options. If you are compiling from the command prompt you can type: gcc yourprogram.c -oyourprogram.cgi -L/[directory of mysql.h file] -lmysqlclient If you are going to work with cgi's you will of course need to make sure your mysql server is up and running and that it is willing to accept connection from you (usually localhost if the cgi is running on the same server as mysql). I hope that helps. b-- On Wed, 2002-03-27 at 00:23, Jonathan wrote: > Hi! I have a problem regarding my cgi script. when i compile my program using devcpp, an error message appear "mysql/mysql.h: no such file or directory" Where can i find this header file or where can i download it? please give me some tips... Thanks. > > My email addresses are jon...@ed... and jon...@ho... > > Thanks again and best regards. |
|
From: Peter <pet...@sp...> - 2002-03-26 22:14:59
|
I tried the Hello World program in C++ 101. It failed miserably with a blue screen of death. I used Control F9 and then F9. Should I try to run it in a Dos window. and how can a cpp extension run? Does it not have to be exe? Peter |
|
From: Ioannis V. <no...@ho...> - 2002-03-26 19:40:52
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Graeme Foster > Sent: Monday, March 25, 2002 4:24 PM > To: dev...@li... > Subject: [Dev-C++] vectors > > When should an array be used and when should a vector be > used? ============================================================== > If you know before hand how many elements will be used then > use an array, if however the number of elements is not known > then use a vector. No, always use vectors and if in need to squeeze every cycle out in terms of speed use valarrays (they have the speed of optimised Fortran arrays). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-03-26 19:37:09
|
-----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Daniel Glenfield Sent: Monday, March 25, 2002 9:47 AM To: d_w...@ho...; dev...@li... Subject: Re: [Dev-C++] Struct tag Thanks. A vector (stop me if I've over-generalised this or am just plain wrong ppl) is an array with built in features such as error checking but can, unless used perfectly, use more resources. Is that ok everyone? :) No. One pays for what he uses. If you need features that occupy some resources, you would occupy the same resources and even more if you use built in arrays and functions getting them as arguments and twiddling their bits. Standard library containers are made small in such way so as the member functions are inlined and we have no time cost. In fact usually we have less time cost than C style code separated in functions! For an example see my tests at: http://users.forthnet.gr/ath/jvr/c++faq.htm Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net <http://www.noicys.cjb.net/> * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-03-26 19:31:30
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Daniel K. O. > Sent: Monday, March 25, 2002 3:41 AM > To: Dev-Cpp-Users > Subject: RES: [Dev-C++] errors > > > Try putting your includes like this: > > #include <iostream.h> > #include <string.h> This is a mistake. The proper ANSI C++ header style is #include <iostream> . iostream.h e.t.c is illegal, in all modern compilers is depricated and is about to removed from future versions. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-03-26 19:28:50
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Danny
Austin
Sent: Monday, March 25, 2002 2:56 AM
To: dev...@li...
Subject: [Dev-C++] errors
HEY GUYS,
I'm that newbie guy that keeps having trouble. I got a book "C++ for
the absolute beginner," well this beginner doesn't still get it. So I'm
wondering if you can explain what the book is failing to explain. Below
is a program I typed in, that is giving me fits over "enum" and all its
"returns" I feel like I missing something in my lib.'s but I'm not sure.
I have double checked everything several times to the book and from all
that I can see I have typed it out just as the book has it. I take it
though one complier will do things differently than another and I know
the author is using a different complier. So if anyone can help me I'm
all ears.
enums are user defined discrete integer types.
THANKS DANNY!!
//6.5 - Tic Tac Toe
#include <iostream>
#include <string>
using namespace std;
enum SquareState { blank = ' ' , X = 'X', 0= '0' };
0='0'?
enum SquareState { blank=' ', X='X', O='0'};
class gameBoard
{
private:
const int WIDTH;
const int HEIGHT;
int* GameBoard;
public:
gameBoard() : WIDTH(3), HEIGHT(3)
{
GameBoard = new int[9];
for (int i = 0; i < 9; i++)
*(GameBoard + i) = blank;
}
~gameBoard() {delete[] GameBoard;}
void setX(int h, int w);
void set0(int h, int w);
bool isTaken(int h, int w);
SquareState isLine();
void draw();
};
void gameBoard::setX(int h, int w)
{
*(GameBoard + h*HEIGHT + w) = X;
}
void gameBoard::set0(int h, int w)
{
*(GameBoard + h*HEIGHT + w) = 0;
}
bool gameBoard::isTaken (int h, int w)
{
return *(GameBoard + h*HEIGHT + w) != ' ';
}
SquareState gameBoard::isLine()
{
if(*GameBoard==X && *(GameBoard +1)==X && *(GameBoard +2)==X)
return X;
if(*GameBoard==0 && *(GameBoard +1)==0 && *(GameBoard +2)==0)
return 0;
0 doesn't belong to type SquareState. Result is truncated.
Ioannis
* Ioannis Vranos
* Programming pages: <http://www.noicys.cjb.net/>
http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|
|
From: Jonathan <jon...@ho...> - 2002-03-26 15:12:40
|
Hi! I have a problem regarding my cgi script. when i compile my program = using devcpp, an error message appear "mysql/mysql.h: no such file or = directory" Where can i find this header file or where can i download it? = please give me some tips... Thanks. My email addresses are jon...@ed... and = jon...@ho... Thanks again and best regards. |
|
From: Benjamin W. <ben...@ho...> - 2002-03-26 12:19:25
|
Good morning, We've had this question not too long ago. My recommendation is Charles Petzold's -- Programming Windows, 5th Ed. His web site is: http://www.charlespetzold.com/home.html It's a hardback, 1500+ page book that covers the Win32 API better than any other book I have ever read. If you are serious about Windows programming, you really should pick up a copy. Hope that helps. Ben Benjamin Wheeless Network Systems - Delta AirLines, Inc. Atlanta, Georgia - USA _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com |
|
From: Santiago P. C. <San...@yd...> - 2002-03-26 09:44:26
|
Hi to *, I'm trying to do 'some_kind_of_port' (I'm not so good programmer to be sure of achiveing that, but I must try ;oD) of a Linux app to Windoze, but I'm finding a lot of errors like this one: D:/path/to/include/folder/include_file.h: macro or `#include' recursion too deep I know this error uses to appear when invoking g++ with '-traditional' flag, but this is not the case, here is my command line: g++ -mconsole -mthreads -shared -c D:\usr\ports\unix\config.cxx -I"D:\usr\ports\include" -I"D:\usr\libs\include" -L"D:\usr\ports\lib" -L"D:\usr\libs\lib" AFAIK this should be solved by using the following structure on all include files: #idnfdef __LIBRARY_NAME__FILENAME_H__ #define __LIBRARY_NAME__FILENAME_H__ ... File contents #endif But, due to the fact that I'm using 'external' libs (like PWLib) it is not possible to modify all include files (everytime a new version of the library is released) to keep them using this structure (and I also think this is not the solution). I'm relatively new to MinGW and Dev-C++ so, any hints on where should I look at? Thanx, Santy -------------------------------------------------------------------------------------- This message and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. No confidentiality or privilege is waived or lost by any wrong transmission. If you have received this message in error, please immediately destroy it and kindly notify the sender by reply email. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Opinions, conclusions and other information in this message that do not relate to the official business of People Communications S.A. shall be understood as neither given nor endorsed by it. -------------------------------------------------------------------------------------- |
|
From: Daniel K. O. <dan...@ya...> - 2002-03-26 07:18:50
|
Hello again I'm starting to use GTK+ with Dev-C++, but I can't even compile the programs. I tried some examples, but nothing works. Can someone help me a little? Any help is welcome (samples, tutorials, URLs, ...). Daniel K. O. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: <gi...@li...> - 2002-03-26 05:45:34
|
At 17:27 24/03/02 +0000, Napoleon Ahiable wrote: >... > >For ease of use much more than anything, I use Context editor since it >allows me to use basically any of the free compilers as well as make. > > Also I find updating the compilers much easier since its just a matter > of downloading and installing. I have Dev-C++ 4.0 but I use ConTEXT most of the times (in fact it enables me to harness powerful Borland BC++ 5.5 compiler): I only write console programs so probably what I say does not suit your case (I know nothing about wxWindows programs). >I however miss Dev C++ and Its ability to enable me work project wise. I don't miss it :) In fact, ConTEXT has projects too (they allow too keep files together, a sort of putting all the sheets in one folder) and also I use a makefile generator which creates "makefiles" that manage programs whose source code is spread across more than one file. > >I will like to know if I can use make to compile wxWindows programs >instead of its default parameters. sorry, too difficult for me to answer. >Generally can I use make to compile in Dev C++. I don't think so, in fact Dev C++ only compiles "projects". Using "make", would mean that Dev C++ had the ability to convert a "makefile" into a "project", and this is something that vers. 4.0 of the program doesn't do, it does the opposite though: I mean that you can write a project (using Dev-C++) then generate a makefile out of the project (actually the result is not a "smart" makefile), finally use "make" and the makefile to compile your program. > >Thanks. Welcome -- gisan gi...@li... |
|
From: Cubs <cu...@ya...> - 2002-03-26 03:31:07
|
Hi, I'm just about done with a book on C++ and know the language fairly well. And I was just wondering if any of you might know where i could learn Windows programming (any books you know of??). Thanks, Simo __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ |
|
From: Kirktoun .....T. C. F. <kir...@bt...> - 2002-03-25 23:32:36
|
I don't know if this is still a live issue but the following works fine =
on bloodshed.
#include <conio.h>
#include <iostream.h>
int main()
{
cout << "Enter any key." << endl;
getche();
cout << " whatever you want to happen leave the program call a =
function??" <<endl;
getche();
return(0);
}
on microsoft visual c++ 6 the following will work.
#include <conio.h>
#include <iostream.h>
int main()
{
cout << "Enter any key." << endl;
while(!kbhit());
return(0);
}
|
|
From: Anders N. <An...@ek...> - 2002-03-25 15:10:12
|
A very good and pedagogical explonation. Answers like this make this =
list great!
Anders Nilsson
----- Ursprungligt meddelande -----=20
Fr=E5n: "Graeme Foster" <gr...@dr...>
Till: <dev...@li...>
Skickat: den 25 mars 2002 15:24
=C4mne: [Dev-C++] vectors
> What is a vector?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> In short a vector one of the containers provided by the Standard =
Template
> Library. A container is a data type that allows objects of a similar =
type to
> be held together. A template allows the data type to be declared when =
the
> container is created. The characteristics of the vector is that it is
> dynamic - that means that when a new element is to be added to the =
container
> then that is done automatically. New elements are added to the end of =
the
> vector, for most efficient results the elements should also be deleted =
from
> the end but it is possible to delete elements from anywhere from =
within the
> vector. Elements in the vector can be accessed randomly using the []
> operators just like the array.
>=20
> So is a vector like an array?
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> I guess that you could say that it's like an array on steroids. It can =
do
> much more than a simple array but with a familiar interface.
>=20
> When should an array be used and when should a vector be used?
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> If you know before hand how many elements will be used then use an =
array, if
> however the number of elements is not known then use a vector.
>=20
> What did you mean by a vector allowing "objects of a similar type to =
be held
> together"?
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> The similar type refers to classes within the class hierarchy. The =
class
> defined as the template can be used along with any derived class. =
Hence a
> vector of person objects will also be able to hold students objects =
and
> lecturer objects, so long as both of these objects are derived from =
the
> person class.
>=20
>=20
> Please give me an example!
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
>=20
> The following may help to clarify things:
>=20
> I have declared a class called allObjects which contains a vector of
> instances of the cObject class:
> +++++++++++++++++++++++++++++++++++
> class cAllObjects
> {
> private:
> vector<cObject *> list;
> public:
> void add(cObject * obj);
> void remove (cObject * obj);
> cObject * get (long OID);
> void dump();
> };
>=20
> The definitions are as follows:
> +++++++++++++++++++++++++++++++++++
> void cAllObjects::add(cObject * obj)
> {
> list.push_back(obj);
> }
>=20
> void cAllObjects::remove (cObject * obj)
> {
> list.erase(find(list.begin(), list.end(), obj));
> }
>=20
> cObject * cAllObjects::get (long OID)
> {
> unsigned int i =3D 0;
> while (i < list.size() && list[i]->OID !=3D OID)
> {
> i++;
> }
> if (i >=3D list.size())
> return 0;
> else
> return list[i];
> }
>=20
> void cAllObjects::dump()
> {
> for (int i =3D 0; i < list.size(); i++)
> list[i]->dump();
> }
>=20
> For this to work the cObject needs to be declared and defined:
> +++++++++++++++++++++++++++++++++++
> class cAllObjects;
> class cObject
> {
> friend cAllObjects;
> private:
> static long nextOID;
> static cAllObjects allObjects;
> long OID;
> string className;
> public:
> static void dumpAll();
> cObject(long pOID =3D nextOID);
> ~cObject();
> void dump();
> };
>=20
> and:
> +++++++++++++++++++++++++++++++++++
> #include "Object.hpp"
>=20
> // Initialise the Static members
> long cObject::nextOID =3D 0;
> cAllObjects cObject::allObjects;
>=20
> void cObject::dumpAll()
> {
> allObjects.dump();
> }
>=20
> // Constructors
> cObject::cObject(long pOID)
> {
> // Add this object to the list
> allObjects.add(this);
> // Check that the OID hasn't yet been used
> if (pOID < nextOID)
> pOID =3D nextOID;
> OID =3D pOID; // assign the unique number to OID
> nextOID =3D pOID + 1; // increment the nextOID by 1
> className =3D "Object";// set the class name to Object
> }
>=20
> // Destructors
> cObject::~cObject()
> {
> // Remove this object from the AllObjects list
> allObjects.remove(this);
> }
>=20
> // Diagnostic methods
> void cObject::dump()
> {
> cout << "OID =3D " << OID << "\n";
> cout << "Class =3D " << className << "\n";
> }
>=20
> This can then be tested using the following main:
> int main(int argc, char* argv[])
> {
> cObject myObject1(5);
> myObject1.dump();
> cObject myObject2(0);
> myObject2.dump();
> cObject myObject3(0);
> myObject3.dump();
> cObject myObject4;
> myObject4.dump();
> cObject::dumpAll();
> cout << "Press any key to finish...\n";
> getch();
> return 0;
> }
>=20
> Files
> =3D=3D=3D=3D=3D
> The declarations of both classes are held in the same file called
> Object.hpp, whilst the source code was held in the their own files.
>=20
> This enables an object to hold all of teh objects that have been =
created,
> they are put onto the vector from within the constructor of the =
cObject
> class. They can all be listed by using the static member function =
dumpAll()
>=20
>=20
>=20
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|
|
From: Graeme F. <gr...@dr...> - 2002-03-25 14:26:39
|
What is a vector?
=================
In short a vector one of the containers provided by the Standard Template
Library. A container is a data type that allows objects of a similar type to
be held together. A template allows the data type to be declared when the
container is created. The characteristics of the vector is that it is
dynamic - that means that when a new element is to be added to the container
then that is done automatically. New elements are added to the end of the
vector, for most efficient results the elements should also be deleted from
the end but it is possible to delete elements from anywhere from within the
vector. Elements in the vector can be accessed randomly using the []
operators just like the array.
So is a vector like an array?
=============================
I guess that you could say that it's like an array on steroids. It can do
much more than a simple array but with a familiar interface.
When should an array be used and when should a vector be used?
==============================================================
If you know before hand how many elements will be used then use an array, if
however the number of elements is not known then use a vector.
What did you mean by a vector allowing "objects of a similar type to be held
together"?
============================================================================
===========
The similar type refers to classes within the class hierarchy. The class
defined as the template can be used along with any derived class. Hence a
vector of person objects will also be able to hold students objects and
lecturer objects, so long as both of these objects are derived from the
person class.
Please give me an example!
==========================
The following may help to clarify things:
I have declared a class called allObjects which contains a vector of
instances of the cObject class:
+++++++++++++++++++++++++++++++++++
class cAllObjects
{
private:
vector<cObject *> list;
public:
void add(cObject * obj);
void remove (cObject * obj);
cObject * get (long OID);
void dump();
};
The definitions are as follows:
+++++++++++++++++++++++++++++++++++
void cAllObjects::add(cObject * obj)
{
list.push_back(obj);
}
void cAllObjects::remove (cObject * obj)
{
list.erase(find(list.begin(), list.end(), obj));
}
cObject * cAllObjects::get (long OID)
{
unsigned int i = 0;
while (i < list.size() && list[i]->OID != OID)
{
i++;
}
if (i >= list.size())
return 0;
else
return list[i];
}
void cAllObjects::dump()
{
for (int i = 0; i < list.size(); i++)
list[i]->dump();
}
For this to work the cObject needs to be declared and defined:
+++++++++++++++++++++++++++++++++++
class cAllObjects;
class cObject
{
friend cAllObjects;
private:
static long nextOID;
static cAllObjects allObjects;
long OID;
string className;
public:
static void dumpAll();
cObject(long pOID = nextOID);
~cObject();
void dump();
};
and:
+++++++++++++++++++++++++++++++++++
#include "Object.hpp"
// Initialise the Static members
long cObject::nextOID = 0;
cAllObjects cObject::allObjects;
void cObject::dumpAll()
{
allObjects.dump();
}
// Constructors
cObject::cObject(long pOID)
{
// Add this object to the list
allObjects.add(this);
// Check that the OID hasn't yet been used
if (pOID < nextOID)
pOID = nextOID;
OID = pOID; // assign the unique number to OID
nextOID = pOID + 1; // increment the nextOID by 1
className = "Object";// set the class name to Object
}
// Destructors
cObject::~cObject()
{
// Remove this object from the AllObjects list
allObjects.remove(this);
}
// Diagnostic methods
void cObject::dump()
{
cout << "OID = " << OID << "\n";
cout << "Class = " << className << "\n";
}
This can then be tested using the following main:
int main(int argc, char* argv[])
{
cObject myObject1(5);
myObject1.dump();
cObject myObject2(0);
myObject2.dump();
cObject myObject3(0);
myObject3.dump();
cObject myObject4;
myObject4.dump();
cObject::dumpAll();
cout << "Press any key to finish...\n";
getch();
return 0;
}
Files
=====
The declarations of both classes are held in the same file called
Object.hpp, whilst the source code was held in the their own files.
This enables an object to hold all of teh objects that have been created,
they are put onto the vector from within the constructor of the cObject
class. They can all be listed by using the static member function dumpAll()
|
|
From: Daniel G. <sp...@ho...> - 2002-03-25 07:47:16
|
<html><div style='background-color:'><DIV> <P>Thanks.</P> <P>A vector (stop me if I've over-generalised this or am just plain wrong ppl) is an array with built in features such as error checking but can, unless used perfectly, use more resources.</P> <P> </P> <P>Is that ok everyone?<BR><BR></P></DIV> <DIV></DIV> <DIV></DIV>>From: "Daniel Wilches" <D_W...@HO...> <DIV></DIV>>To: "DEV-C++" <DEV...@LI...> <DIV></DIV>>Subject: Re: [Dev-C++] Struct tag <DIV></DIV>>Date: Sun, 24 Mar 2002 15:44:54 -0500 <DIV></DIV>> <DIV></DIV>>OK, i ll answer your first question, the second: what the heck is a vector, i dont know <DIV></DIV>> <DIV></DIV>>the difference between classes and structs is that in a class all the members are, for default, private, and in a struct are public by default. No more, thats the difference. <DIV></DIV></div><br clear=all><hr>MSN Photos is the easiest way to share and print your photos: <a href='http://g.msn.com/1HM305301/14'>Click Here</a><br></html> |
|
From: Jason H. <jas...@bt...> - 2002-03-25 03:35:31
|
The errors you are getting are all due to simple typing errors. If you =
look in the enum you have substituted the number 0 with the letter O, =
notice the subtle difference in width between letter and number. So =
where you have previously put zero you need to put the letter O, but =
only for the lines dealing with the enumeration, and returning an =
enumeration type. Another mistype you have is where a ) bracket has been =
substituted for a } brace.
If you go through the errors double clicking the top one and correct the =
error, and then recompiling eventualy you will get a full compile. =
However I suggest you look at the code as the game doesn't apear to work =
properly, so there may be other more subtle erros, maybe mistyped =
numbers etc...
Jason.
----- Original Message -----=20
From: Danny Austin=20
To: dev...@li...=20
Sent: Monday, March 25, 2002 12:55 AM
Subject: [Dev-C++] errors
HEY GUYS,
I'm that newbie guy that keeps having trouble. I got a book "C++ for =
the absolute beginner," well this beginner doesn't still get it. So I'm =
wondering if you can explain what the book is failing to explain. Below =
is a program I typed in, that is giving me fits over "enum" and all its =
"returns" I feel like I missing something in my lib.'s but I'm not sure. =
I have double checked everything several times to the book and from all =
that I can see I have typed it out just as the book has it. I take it =
though one complier will do things differently than another and I know =
the author is using a different complier. So if anyone can help me I'm =
all ears. =20
THANKS DANNY!!
//6.5 - Tic Tac Toe
#include <iostream>
#include <string>
using namespace std;
enum SquareState { blank =3D ' ' , X =3D 'X', 0=3D '0' };
class gameBoard
{
private:
const int WIDTH;
const int HEIGHT;
int* GameBoard;
public:
gameBoard() : WIDTH(3), HEIGHT(3)
{
GameBoard =3D new int[9];
for (int i =3D 0; i < 9; i++)
*(GameBoard + i) =3D blank;
}
~gameBoard() {delete[] GameBoard;}
void setX(int h, int w);
void set0(int h, int w);
bool isTaken(int h, int w);
SquareState isLine();
void draw();
};
void gameBoard::setX(int h, int w)
{
*(GameBoard + h*HEIGHT + w) =3D X;
}
void gameBoard::set0(int h, int w)
{
*(GameBoard + h*HEIGHT + w) =3D 0;
}
bool gameBoard::isTaken (int h, int w)
{
return *(GameBoard + h*HEIGHT + w) !=3D ' ';
}
SquareState gameBoard::isLine()
{
if(*GameBoard=3D=3DX && *(GameBoard +1)=3D=3DX && *(GameBoard =
+2)=3D=3DX)
return X;
if(*GameBoard=3D=3D0 && *(GameBoard +1)=3D=3D0 && *(GameBoard =
+2)=3D=3D0)
return 0;
if(*(GameBoard +3)=3D=3DX && *(GameBoard +4)=3D=3DX && =
*(GameBoard +5)=3D=3DX)
return X;
if(*(GameBoard +3)=3D=3D0 && *(GameBoard +4)=3D=3D0 && =
*(GameBoard +5)=3D=3D0)
return 0;
if(*(GameBoard +6)=3D=3DX && *(GameBoard +7)=3D=3DX && =
*(GameBoard +8)=3D=3DX)
return X;
if(*(GameBoard +6)=3D=3D0 && *(GameBoard +7)=3D=3D0 && =
*(GameBoard +8)=3D=3D0)
return 0;
=20
if(*GameBoard=3D=3DX && *(GameBoard +3)=3D=3DX && *(GameBoard =
+6)=3D=3DX)
return X;
if(*GameBoard=3D=3D0 && *(GameBoard +3)=3D=3D0 && *(GameBoard =
+6)=3D=3D0)
return 0;
if(*(GameBoard +1)=3D=3DX && *(GameBoard +4)=3D=3DX && =
*(GameBoard +7)=3D=3DX)
return X;
if(*(GameBoard +1)=3D=3D0 && *(GameBoard +4)=3D=3D0 && =
*(GameBoard +7)=3D=3D0)
return 0;
if(*(GameBoard +2)=3D=3DX && *(GameBoard +5)=3D=3DX && =
*(GameBoard +8)=3D=3DX)
return X;
if(*(GameBoard +2)=3D=3D0 && *(GameBoard +5)=3D=3D0 && =
*(GameBoard +8)=3D=3D0)
return 0;
=20
if(*GameBoard=3D=3DX && *(GameBoard +4)=3D=3DX && *(GameBoard =
+8)=3D=3DX)
return X;
if(*GameBoard=3D=3D0 && *(GameBoard +4)=3D=3D0 && *(GameBoard =
+8)=3D=3D0)
return 0;
if(*(GameBoard +2)=3D=3DX && *(GameBoard +4)=3D=3DX && =
*(GameBoard +6)=3D=3DX)
return X;
if(*(GameBoard +2)=3D=3D0 && *(GameBoard +4)=3D=3D0 && =
*(GameBoard +6)=3D=3D0)
return 0;
return blank;
=20
}
void gameBoard::draw()
{
cout << endl;
for(int i=3D0; i < HEIGHT; i++)
{
cout << (char)*(GameBoard + i*HEIGHT);
for(int c=3D1; c < WIDTH; c++)
cout << " | " << (char)*(GameBoard + i*WIDTH + =
c);
cout << endl << "-------" << endl;
}
}
class Game
{
public:
gameBoard* doInput(string player, gameBoard* gb);
bool inRange(int test);
};
gameBoard* Game::doInput(string player, gameBoard* gb)
{
gb->draw();
=20
string letter;
if (player.compare("one") =3D=3D 0)
letter =3D "X";
else if (player.compare("two") =3D=3D 0)
letter =3D "0";
else return gb;
=20
int input1, input2;
=20
do {
=20
do {
cout << "\nPlayer " << player.c_str()
<< ", please enter a row number to put an "
<< letter.c_str() << ": ";
cin >> input1;
}while(!inRange(input1));
=20
do {
cout << "\nPlease enter a column number to put an "
<< letter.c_str() << ": ";
cin >> input2;
}while(!inRange(input2));
=20
}while (gb->isTaken(input1,input2));
=20
if (player.compare("one") =3D=3D 0)
gb->setX(input1, input2);
else gb->set0(input1, input2);
=20
return gb;
=20
}
bool Game::inRange(int test)
{
return test > -1 && test < 3;
)
int main( void )
{
gameBoard* gb =3D new gameBoard;
Game g;
string player1, player2;
cout << "Welcome to Tic Tac Toe!"
<< "\nPlayer one, please enter your name: ";
cin >> player1;
cout << "\nPlayer two, please enter your name: ";
cin >> player2;
=20
while (gb->isLine() =3D=3D ' ')
{
gb =3D g.doInput("one",gb);
gb =3D g.doInput("two",gb);
}
gb->draw();
if(gb->isLine() =3D=3D X)
cout << "\nPlayer one, you win!"
<< "\nGame Over.";
else cout << "\nPlayer two, you win!"
<< "\nGame Over.";
return 0;
}
|
|
From: Jason H. <jas...@bt...> - 2002-03-25 03:35:25
|
As I understand it 4.9.1 is a beta (alpha?) release for the upcoming v5 of Dev-C++ so it's bound to be little buggy. Your best bet would be to report the problems you are having. They will need more information about the exact steps you are taking and the system you are working with before they can adivise you and fix the problem. For a more stable release try v4.01. Jason. ----- Original Message ----- From: "Daniel K. O." <dan...@ya...> To: "Dev-Cpp-Users" <dev...@li...> Sent: Sunday, March 24, 2002 9:27 PM Subject: [Dev-C++] Problems > Hello people > > > I'm new on Dev-C++, and I'm having some problems with the version 4.9.1 > > It crashes all the time, when I try to compile something, and I get a bsod. > > What I'm doing wrong? > > > > > > Thanks for any help. > > > > > > =-=-=-=-=-=-= > I've got a Mickey Mouse PC with a Goofy operating system > =-=-=-=-=-=-= > > ============================= > Daniel K. O. > ----------------------------- > Computer Science - UNISC > http://www.unisc.br > ============================= > ICQ# 117887205 > http://danielko.cjb.net > dan...@ie... > dan...@ya... > > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Daniel W. <d_w...@ho...> - 2002-03-25 02:45:36
|
What happen is that the version 4.9.1 is a beta version and beta means = crashes and bugs, i downloaded that version but for the same problem i = downloaded the version 4.0.1 I think is for that Daniel Wilches M. dwi...@ma... |
|
From: Brian C. B. <bcb...@ya...> - 2002-03-25 01:46:08
|
Hi Daniel, >I'm new on Dev-C++, and I'm having some problems with the version 4.9.1 > >It crashes all the time, when I try to compile something, and I get a bsod. > >What I'm doing wrong? Nothing. Version 4.9.1 is code named Dev-C++ 5 Beta, so it is pretty buggy. I would suggest that you use the older version until all the bugs are worked out (you help speed the process up by submitting bug reports :) ). You can get the old version at http://www.bloodshed.net/dev/devcpp.html . Scroll down until you see the section entitled 'Dev-C++ 4'. Sincerely, Brian Becker Shall we accept good from God, and not trouble? --- Outgoing mail is certified Virus Free by AVG Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.338 / Virus Database: 189 - Release Date: 3/14/2002 |
|
From: Daniel K. O. <dan...@ya...> - 2002-03-25 01:41:28
|
Try putting your includes like this:
#include <iostream.h>
#include <string.h>
And I noticed the identifiers you're using in the enum type:
enum SquareState { blank = ' ' , X = 'X', 0= '0' };
Look: you're using 0 (zero) instead O (letter). Identifiers shouldn't start
with a digit, like 0 (zero).
The same where you're returning zero instead O.
Hope this can help you.
=============================
Daniel K. O.
-----------------------------
Computer Science - UNISC
http://www.unisc.br
=============================
ICQ# 117887205
http://danielko.cjb.net
dan...@ie...
dan...@ya...
-----Mensagem original-----
De: dev...@li...
[mailto:dev...@li...]Em nome de Danny Austin
Enviada em: domingo, 24 de março de 2002 21:56
Para: dev...@li...
Assunto: [Dev-C++] errors
HEY GUYS,
I'm that newbie guy that keeps having trouble. I got a book "C++ for the
absolute beginner," well this beginner doesn't still get it. So I'm
wondering if you can explain what the book is failing to explain. Below is
a program I typed in, that is giving me fits over "enum" and all its
"returns" I feel like I missing something in my lib.'s but I'm not sure. I
have double checked everything several times to the book and from all that I
can see I have typed it out just as the book has it. I take it though one
complier will do things differently than another and I know the author is
using a different complier. So if anyone can help me I'm all ears.
THANKS DANNY!!
//6.5 - Tic Tac Toe
#include <iostream>
#include <string>
using namespace std;
enum SquareState { blank = ' ' , X = 'X', 0= '0' };
class gameBoard
{
private:
const int WIDTH;
const int HEIGHT;
int* GameBoard;
public:
gameBoard() : WIDTH(3), HEIGHT(3)
{
GameBoard = new int[9];
for (int i = 0; i < 9; i++)
*(GameBoard + i) = blank;
}
~gameBoard() {delete[] GameBoard;}
void setX(int h, int w);
void set0(int h, int w);
bool isTaken(int h, int w);
SquareState isLine();
void draw();
};
void gameBoard::setX(int h, int w)
{
*(GameBoard + h*HEIGHT + w) = X;
}
void gameBoard::set0(int h, int w)
{
*(GameBoard + h*HEIGHT + w) = 0;
}
bool gameBoard::isTaken (int h, int w)
{
return *(GameBoard + h*HEIGHT + w) != ' ';
}
SquareState gameBoard::isLine()
{
if(*GameBoard==X && *(GameBoard +1)==X && *(GameBoard +2)==X)
return X;
if(*GameBoard==0 && *(GameBoard +1)==0 && *(GameBoard +2)==0)
return 0;
if(*(GameBoard +3)==X && *(GameBoard +4)==X && *(GameBoard +5)==X)
return X;
if(*(GameBoard +3)==0 && *(GameBoard +4)==0 && *(GameBoard +5)==0)
return 0;
if(*(GameBoard +6)==X && *(GameBoard +7)==X && *(GameBoard +8)==X)
return X;
if(*(GameBoard +6)==0 && *(GameBoard +7)==0 && *(GameBoard +8)==0)
return 0;
if(*GameBoard==X && *(GameBoard +3)==X && *(GameBoard +6)==X)
return X;
if(*GameBoard==0 && *(GameBoard +3)==0 && *(GameBoard +6)==0)
return 0;
if(*(GameBoard +1)==X && *(GameBoard +4)==X && *(GameBoard +7)==X)
return X;
if(*(GameBoard +1)==0 && *(GameBoard +4)==0 && *(GameBoard +7)==0)
return 0;
if(*(GameBoard +2)==X && *(GameBoard +5)==X && *(GameBoard +8)==X)
return X;
if(*(GameBoard +2)==0 && *(GameBoard +5)==0 && *(GameBoard +8)==0)
return 0;
if(*GameBoard==X && *(GameBoard +4)==X && *(GameBoard +8)==X)
return X;
if(*GameBoard==0 && *(GameBoard +4)==0 && *(GameBoard +8)==0)
return 0;
if(*(GameBoard +2)==X && *(GameBoard +4)==X && *(GameBoard +6)==X)
return X;
if(*(GameBoard +2)==0 && *(GameBoard +4)==0 && *(GameBoard +6)==0)
return 0;
return blank;
}
void gameBoard::draw()
{
cout << endl;
for(int i=0; i < HEIGHT; i++)
{
cout << (char)*(GameBoard + i*HEIGHT);
for(int c=1; c < WIDTH; c++)
cout << " | " << (char)*(GameBoard + i*WIDTH + c);
cout << endl << "-------" << endl;
}
}
class Game
{
public:
gameBoard* doInput(string player, gameBoard* gb);
bool inRange(int test);
};
gameBoard* Game::doInput(string player, gameBoard* gb)
{
gb->draw();
string letter;
if (player.compare("one") == 0)
letter = "X";
else if (player.compare("two") == 0)
letter = "0";
else return gb;
int input1, input2;
do {
do {
cout << "\nPlayer " << player.c_str()
<< ", please enter a row number to put an "
<< letter.c_str() << ": ";
cin >> input1;
}while(!inRange(input1));
do {
cout << "\nPlease enter a column number to put an "
<< letter.c_str() << ": ";
cin >> input2;
}while(!inRange(input2));
}while (gb->isTaken(input1,input2));
if (player.compare("one") == 0)
gb->setX(input1, input2);
else gb->set0(input1, input2);
return gb;
}
bool Game::inRange(int test)
{
return test > -1 && test < 3;
)
int main( void )
{
gameBoard* gb = new gameBoard;
Game g;
string player1, player2;
cout << "Welcome to Tic Tac Toe!"
<< "\nPlayer one, please enter your name: ";
cin >> player1;
cout << "\nPlayer two, please enter your name: ";
cin >> player2;
while (gb->isLine() == ' ')
{
gb = g.doInput("one",gb);
gb = g.doInput("two",gb);
}
gb->draw();
if(gb->isLine() == X)
cout << "\nPlayer one, you win!"
<< "\nGame Over.";
else cout << "\nPlayer two, you win!"
<< "\nGame Over.";
return 0;
}
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|
|
From: Danny A. <tam...@ms...> - 2002-03-25 00:51:31
|
HEY GUYS,
I'm that newbie guy that keeps having trouble. I got a book "C++ for the=
absolute beginner," well this beginner doesn't still get it. So I'm won=
dering if you can explain what the book is failing to explain. Below is =
a program I typed in, that is giving me fits over "enum" and all its "ret=
urns" I feel like I missing something in my lib.'s but I'm not sure. I h=
ave double checked everything several times to the book and from all that=
I can see I have typed it out just as the book has it. I take it though=
one complier will do things differently than another and I know the auth=
or is using a different complier. So if anyone can help me I'm all ears.=
=20
THANKS DANNY!!
//6.5 - Tic Tac Toe
#include <iostream>
#include <string>
using namespace std;
enum SquareState { blank =3D ' ' , X =3D 'X', 0=3D '0' };
class gameBoard
{
private:
const int WIDTH;
const int HEIGHT;
int* GameBoard;
public:
gameBoard() : WIDTH(3), HEIGHT(3)
{
GameBoard =3D new int[9];
for (int i =3D 0; i < 9; i++)
*(GameBoard + i) =3D blank;
}
~gameBoard() {delete[] GameBoard;}
void setX(int h, int w);
void set0(int h, int w);
bool isTaken(int h, int w);
SquareState isLine();
void draw();
};
void gameBoard::setX(int h, int w)
{
*(GameBoard + h*HEIGHT + w) =3D X;
}
void gameBoard::set0(int h, int w)
{
*(GameBoard + h*HEIGHT + w) =3D 0;
}
bool gameBoard::isTaken (int h, int w)
{
return *(GameBoard + h*HEIGHT + w) !=3D ' ';
}
SquareState gameBoard::isLine()
{
if(*GameBoard=3D=3DX && *(GameBoard +1)=3D=3DX && *(GameBoard +2)=3D=
=3DX)
return X;
if(*GameBoard=3D=3D0 && *(GameBoard +1)=3D=3D0 && *(GameBoard +2)=3D=
=3D0)
return 0;
if(*(GameBoard +3)=3D=3DX && *(GameBoard +4)=3D=3DX && *(GameBoard +=
5)=3D=3DX)
return X;
if(*(GameBoard +3)=3D=3D0 && *(GameBoard +4)=3D=3D0 && *(GameBoard +=
5)=3D=3D0)
return 0;
if(*(GameBoard +6)=3D=3DX && *(GameBoard +7)=3D=3DX && *(GameBoard +=
8)=3D=3DX)
return X;
if(*(GameBoard +6)=3D=3D0 && *(GameBoard +7)=3D=3D0 && *(GameBoard +=
8)=3D=3D0)
return 0;
=20
if(*GameBoard=3D=3DX && *(GameBoard +3)=3D=3DX && *(GameBoard +6)=3D=
=3DX)
return X;
if(*GameBoard=3D=3D0 && *(GameBoard +3)=3D=3D0 && *(GameBoard +6)=3D=
=3D0)
return 0;
if(*(GameBoard +1)=3D=3DX && *(GameBoard +4)=3D=3DX && *(GameBoard +=
7)=3D=3DX)
return X;
if(*(GameBoard +1)=3D=3D0 && *(GameBoard +4)=3D=3D0 && *(GameBoard +=
7)=3D=3D0)
return 0;
if(*(GameBoard +2)=3D=3DX && *(GameBoard +5)=3D=3DX && *(GameBoard +=
8)=3D=3DX)
return X;
if(*(GameBoard +2)=3D=3D0 && *(GameBoard +5)=3D=3D0 && *(GameBoard +=
8)=3D=3D0)
return 0;
=20
if(*GameBoard=3D=3DX && *(GameBoard +4)=3D=3DX && *(GameBoard +8)=3D=
=3DX)
return X;
if(*GameBoard=3D=3D0 && *(GameBoard +4)=3D=3D0 && *(GameBoard +8)=3D=
=3D0)
return 0;
if(*(GameBoard +2)=3D=3DX && *(GameBoard +4)=3D=3DX && *(GameBoard +=
6)=3D=3DX)
return X;
if(*(GameBoard +2)=3D=3D0 && *(GameBoard +4)=3D=3D0 && *(GameBoard +=
6)=3D=3D0)
return 0;
return blank;
=20
}
void gameBoard::draw()
{
cout << endl;
for(int i=3D0; i < HEIGHT; i++)
{
cout << (char)*(GameBoard + i*HEIGHT);
for(int c=3D1; c < WIDTH; c++)
cout << " | " << (char)*(GameBoard + i*WIDTH + c);
cout << endl << "-------" << endl;
}
}
class Game
{
public:
gameBoard* doInput(string player, gameBoard* gb);
bool inRange(int test);
};
gameBoard* Game::doInput(string player, gameBoard* gb)
{
gb->draw();
=20
string letter;
if (player.compare("one") =3D=3D 0)
letter =3D "X";
else if (player.compare("two") =3D=3D 0)
letter =3D "0";
else return gb;
=20
int input1, input2;
=20
do {
=20
do {
cout << "\nPlayer " << player.c_str()
<< ", please enter a row number to put an "
<< letter.c_str() << ": ";
cin >> input1;
}while(!inRange(input1));
=20
do {
cout << "\nPlease enter a column number to put an "
<< letter.c_str() << ": ";
cin >> input2;
}while(!inRange(input2));
=20
}while (gb->isTaken(input1,input2));
=20
if (player.compare("one") =3D=3D 0)
gb->setX(input1, input2);
else gb->set0(input1, input2);
=20
return gb;
=20
}
bool Game::inRange(int test)
{
return test > -1 && test < 3;
)
int main( void )
{
gameBoard* gb =3D new gameBoard;
Game g;
string player1, player2;
cout << "Welcome to Tic Tac Toe!"
<< "\nPlayer one, please enter your name: ";
cin >> player1;
cout << "\nPlayer two, please enter your name: ";
cin >> player2;
=20
while (gb->isLine() =3D=3D ' ')
{
gb =3D g.doInput("one",gb);
gb =3D g.doInput("two",gb);
}
gb->draw();
if(gb->isLine() =3D=3D X)
cout << "\nPlayer one, you win!"
<< "\nGame Over.";
else cout << "\nPlayer two, you win!"
<< "\nGame Over.";
return 0;
}
|
|
From: Daniel K. O. <dan...@ya...> - 2002-03-24 21:28:08
|
Hello people
I'm new on Dev-C++, and I'm having some problems with the version 4.9.1
It crashes all the time, when I try to compile something, and I get a bsod.
What I'm doing wrong?
Thanks for any help.
=-=-=-=-=-=-=
I've got a Mickey Mouse PC with a Goofy operating system
=-=-=-=-=-=-=
=============================
Daniel K. O.
-----------------------------
Computer Science - UNISC
http://www.unisc.br
=============================
ICQ# 117887205
http://danielko.cjb.net
dan...@ie...
dan...@ya...
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|
|
From: Daniel W. <d_w...@ho...> - 2002-03-24 20:42:17
|
OK, i ll answer your first question, the second: what the heck is a = vector, i dont know the difference between classes and structs is that in a class all the = members are, for default, private, and in a struct are public by = default. No more, thats the difference. |