December 21, 2006
I am just starting out in C++ one tut I have been using give me a roll dice program pretty much I have followed his steps perfectly but an dgetting this:

.objs\main.o:main.cpp:(.text+0x13f): undefined reference to
`rollDice()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

everytime I try and build. I am using codeblocks.

Below is a copy of the code I am using any help would be much appreciated.


#include <iostream>
#include <ctime>

using namespace std;

void rollDice (void);

 int main()

{
    srand(time (0));

	rollDice();

	return 0;
}

void rolldice(void)
{
    int die1;
    int die2;

    die1 = 1 + rand() % 6;
    die2 = 1 + rand() % 6;
    cout <<"the first dice is"<<die1 <<endl;
    cout <<"the second dice is"<<die2 <<endl;
}


December 21, 2006
OoPs-Tk wrote:
> I am just starting out in C++ one tut I have been using give me a
> roll dice program pretty much I have followed his steps perfectly
> but an dgetting this:

Um... this is a newsgroup for the D programming language.
You should ask this on a C++ newsgroup.
(But hint -- C++ is case-sensitive.  rolldice!=rollDice).

--bb

> 
> .objs\main.o:main.cpp:(.text+0x13f): undefined reference to
> `rollDice()'
> collect2: ld returned 1 exit status
> Process terminated with status 1 (0 minutes, 0 seconds)
> 0 errors, 0 warnings
> 
> everytime I try and build. I am using codeblocks.
> 
> Below is a copy of the code I am using any help would be much
> appreciated.
> 
> 
> #include <iostream>
> #include <ctime>
> 
> using namespace std;
> 
> void rollDice (void);
> 
>  int main()
> 
> {
>     srand(time (0));
> 
> 	rollDice();
> 
> 	return 0;
> }
> 
> void rolldice(void)
> {
>     int die1;
>     int die2;
> 
>     die1 = 1 + rand() % 6;
>     die2 = 1 + rand() % 6;
>     cout <<"the first dice is"<<die1 <<endl;
>     cout <<"the second dice is"<<die2 <<endl;
> }
> 
> 
1 2
Next ›   Last »