Thread: Random Number Generator Program...PLEASE HELP!!

  1. #16
    Registered User
    Join Date
    Feb 2009
    Posts
    10
    These are the errors I get using Visual Studio

    1>------ Build started: Project: DEMO2, Configuration: Debug Win32 ------
    1>Compiling...
    1>rng.cpp
    1>main.cpp
    1>Generating Code...
    1>Compiling manifest to resources...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>Linking...
    1>main.obj : error LNK2005: "public: __thiscall aRandomNumberGenerator::aRandomNumberGenerator(voi d)" (??0aRandomNumberGenerator@@QAE@XZ) already defined in rng.obj
    1>main.obj : error LNK2005: "public: void __thiscall aRandomNumberGenerator::setSeed(unsigned long)" (?setSeed@aRandomNumberGenerator@@QAEXK@Z) already defined in rng.obj
    1>main.obj : error LNK2005: "public: double __thiscall aRandomNumberGenerator::generate(void)" (?generate@aRandomNumberGenerator@@QAENXZ) already defined in rng.obj
    1>C:\Users\Neesha\Documents\Visual Studio 2008\Projects\DEMO2\Debug\DEMO2.exe : fatal error LNK1169: one or more multiply defined symbols found
    1>Build log was saved at "file://c:\Users\Neesha\Documents\Visual Studio 2008\Projects\DEMO2\Debug\BuildLog.htm"
    1>DEMO2 - 4 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  2. #17
    Registered User
    Join Date
    Feb 2009
    Posts
    10
    I fixed the errors and my program works now

    THANKS FOR ALL THE HELP!!!!!

  3. #18
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by girly_engineer View Post
    I fixed the errors and my program works now

    THANKS FOR ALL THE HELP!!!!!
    The code might seem to be working now but be aware that there are a couple of things your teacher might frown upon in the code that Skreaminskull gave you:

    First of all, don't ever include a .cpp file, it's wrong, we only include .h or .hpp files, never .cpp!

    Second of all, the code never calls the setseed() function, so the number will not be random at all.

    Third of all, your setseed() function doesn't utilize the unsigned int parameter that you gave it, it just uses some magic number which is not only a poor way of coding, it also looks unfinished, as if you wrote the code to test the functionality and then never finished it?
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random number guessing game
    By kazoo in forum C Programming
    Replies: 7
    Last Post: 05-30-2010, 11:31 AM
  2. Simple XOR Program
    By dolfaniss in forum C Programming
    Replies: 8
    Last Post: 05-24-2010, 01:27 PM
  3. random number generator help
    By mayoussa89 in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2010, 07:26 AM
  4. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  5. random number between negative and positive number
    By anomaly in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2003, 08:40 AM