Click here to Skip to main content
16,010,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get the index of the current hot item of the CListCtrl? Pin
Michael Dunn25-May-03 22:30
sitebuilderMichael Dunn25-May-03 22:30 
GeneralReally strange problem , solution !!! :-) Pin
Cedric Moonen25-May-03 20:53
Cedric Moonen25-May-03 20:53 
GeneralRe: Really strange problem , solution !!! :-) Pin
Rage25-May-03 22:39
professionalRage25-May-03 22:39 
GeneralRe: Really strange problem , solution !!! :-) Pin
Neville Franks25-May-03 22:46
Neville Franks25-May-03 22:46 
GeneralGet File Type Extenstons.......... Pin
rohit.dhamija25-May-03 20:44
rohit.dhamija25-May-03 20:44 
GeneralRe: Get File Type Extenstons.......... Pin
Rage25-May-03 22:57
professionalRage25-May-03 22:57 
GeneralRe: Get File Type Extenstons.......... Pin
rohit.dhamija25-May-03 23:33
rohit.dhamija25-May-03 23:33 
QuestionWill the professional programmers please help me here with my DieClass? Pin
Link260025-May-03 19:15
Link260025-May-03 19:15 
Hi,
Have anyone ever played D&D games? I want to write a
program(in console mode) that will give you a random
number, so I write the Die class. But I have tons of
errors even I have debugged it so many times.(still
tons of) I hope some of you would help me out here.

There are 18 errors, 1 warning

This is how I did that:
I use VS.Net, Visual C++ => Win32 Project => console
application => empty project.
I divided it into three files, the driver, the implementation
and the header. Here is the code:

<br />
// DieTest.cpp<br />
// the driver<br />
<br />
#include "Die.h"<br />
#include < iostream ><br />
using namespace std;<br />
<br />
void main()<br />
{<br />
	 Die d1, d2;<br />
	 Die d3(10), d4(100);<br />
<br />
	 cout << "d1\td2\td3\td4" << endl;<br />
<br />
	 for (int i=0; i<10; ++i)<br />
	 {<br />
		 // roll() is modifier<br />
		 d1.roll();<br />
		 d2.roll();<br />
		 d3.roll();<br />
		 d4.roll();<br />
<br />
		 // getValue() is asscessor<br />
		 cout << d1.getValue() << '\t';<br />
		 cout << d2.getValue() << '\t';<br />
		 cout << d3.getValue() << '\t';<br />
		 cout << d4.getValue() << '\t';<br />
	 }<br />
}<br />



<br />
// Die.cpp<br />
// the implementation<br />
<br />
#include <cstdlib><br />
#include <ctime><br />
#include "Die.h"<br />
<br />
Die::Die() // Die() is a constructor<br />
{<br />
	 nSides = DEFSIDES;<br />
	 value = 1;<br />
}<br />
<br />
Die::Die(int sides)<br />
{<br />
	 nSides = sides;<br />
	 value =1;<br />
	 srand (unsigned (time null)));<br />
<br />
}<br />
<br />
void Die::roll() // roll() is a modifier<br />
{<br />
	 value = (srand()%nSides)+1);<br />
}<br />


<br />
//Die.h<br />
// the header<br />
<br />
#ifndef DIE_h<br />
#define DIE_h<br />
<br />
const int DEFSIDES = 6;<br />
<br />
class Die<br />
{<br />
 public:<br />
	 // constructor<br />
	 Die();<br />
	 Die(int);<br />
<br />
	 // modifier<br />
	 void roll();<br />
	<br />
	 // asscessor<br />
	 int getValue() const ( return value; )<br />
<br />
 Private:<br />
	 int nSides;<br />
	 int value;<br />
<br />
};<br />
<br />
#endif<br />
<br />

AnswerRe: Will the professional programmers please help me here with my DieClass? Pin
Michael Dunn25-May-03 19:33
sitebuilderMichael Dunn25-May-03 19:33 
AnswerRe: Will the professional programmers please help me here with my DieClass? Pin
Xander8025-May-03 19:35
Xander8025-May-03 19:35 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Link260025-May-03 20:30
Link260025-May-03 20:30 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Rage25-May-03 22:51
professionalRage25-May-03 22:51 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Link260025-May-03 23:11
Link260025-May-03 23:11 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Rage25-May-03 23:34
professionalRage25-May-03 23:34 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Link260026-May-03 0:17
Link260026-May-03 0:17 
Generalwebbrowser Pin
imajit25-May-03 19:12
imajit25-May-03 19:12 
GeneralWeb Crawler or Web Spider Books Pin
Steve ParmIey25-May-03 17:42
Steve ParmIey25-May-03 17:42 
Generalwebbrowser Pin
imajit25-May-03 17:39
imajit25-May-03 17:39 
GeneralRe: webbrowser Pin
Michael Dunn25-May-03 19:06
sitebuilderMichael Dunn25-May-03 19:06 
Generalmfc and &quot;switch&quot; statements Pin
shanila25-May-03 16:52
shanila25-May-03 16:52 
GeneralRe: mfc and &quot;switch&quot; statements Pin
John R. Shaw26-May-03 10:55
John R. Shaw26-May-03 10:55 
GeneralMFC dialog enigma Pin
Beer25-May-03 16:08
Beer25-May-03 16:08 
QuestionHow do I check for stack oevrflow in recursive functions Pin
Rahul Singh25-May-03 15:09
Rahul Singh25-May-03 15:09 
AnswerRe: How do I check for stack oevrflow in recursive functions Pin
ZoogieZork25-May-03 16:55
ZoogieZork25-May-03 16:55 
GeneralRe: How do I check for stack oevrflow in recursive functions Pin
Neville Franks25-May-03 23:34
Neville Franks25-May-03 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.