Thread: Object not declared in this scope

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    Object not declared in this scope

    I was wondering why I got this error:

    src/test.cpp: In function âint main(int, char**)â:
    src/test.cpp:21: error: âExperimentâ was not declared in this scope
    src/test.cpp:21: error: âexâ was not declared in this scope
    src/test.cpp:21: error: expected type-specifier before âExperimentâ
    src/test.cpp:21: error: expected `;' before âExperimentâ

    The constructor for Experiment was declared as public

    Code:
    public:
    	// default constructor
    	Experiment( );
    	// user's input constructor
    	Experiment(double bias);
    Last edited by -EquinoX-; 08-30-2009 at 01:02 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Post the smallest and simplest program that demonstrates the error.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Object destroy itself?
    By cminusminus in forum C++ Programming
    Replies: 28
    Last Post: 03-27-2008, 01:08 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  5. mega compile errors for small program
    By s_UNI_ in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2005, 12:00 PM