Error not declared in this scope

This is a discussion on Error not declared in this scope within the C++ Programming forums, part of the General Programming Boards category; I am trying to practice my programming skills by writing a program to mess around with my friends in class. ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    2

    Error not declared in this scope

    I am trying to practice my programming skills by writing a program to mess around with my friends in class. But I am having some trouble doing it.
    Here is what I wrote and the error I am receiving.
    Name:  CSI.PNG
Views: 227
Size:  41.4 KB

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,616
    You need to quote the string literal, i.e., "michael" not michael. Also, the correct header for std::string is <string>, not <cstring>. <cstring> is for functions - inherited from C - that work with null terminated strings. You should explicitly declare main as returning an int.
    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

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    2
    Man that was obvious. I have a lot to learn. But thank you for answering my question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Not declared in this scope Error, Templates
    By gbman88 in forum C++ Programming
    Replies: 13
    Last Post: 01-19-2011, 05:40 PM
  2. error: Ďfutexí was not declared in this scope
    By crazyinlove in forum Linux Programming
    Replies: 4
    Last Post: 12-20-2010, 04:59 PM
  3. error PATH_MAX was not declared in this scope
    By kiros88 in forum C++ Programming
    Replies: 2
    Last Post: 04-02-2010, 06:36 PM
  4. xy was not declared in this scope: compiler error!
    By twilight in forum C++ Programming
    Replies: 41
    Last Post: 08-13-2009, 12:33 PM
  5. Replies: 2
    Last Post: 02-12-2005, 05:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21