Thread: was not declared in this scope

  1. #16
    Registered User
    Join Date
    Jun 2021
    Posts
    31
    Okay the reason I wrote that line of code is because I'm working on a open source program and it requires me to fix a couple things


    I have no idea what Sequence or what the line of code does, I'm actually following a tutorial guide and some stuff doesn't compile correctly so I'm just trying to fix it


    By searching the rest of the code I found out that Sequence is declared in packet.hpp just like I said before and packet.hpp is also included


    But for some reason it's still saying Sequence is not declared in scope even though it is declared in packet.hpp like this
    Code:
    unsigned short Sequence();

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,322
    Check the namespaces involved.
    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. #18
    Registered User
    Join Date
    Jun 2021
    Posts
    31
    How do I go about that?

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,322
    Um, obviously you search packet.hpp for namespace and see if the declaration is within a namespace.

    Quote Originally Posted by kotacoder
    I am noob -.- when it comes to programming haha but I am learning slowly
    Instead of trying to dive into an open source project, you might want to work through an introductory tutorial. I say this because "How do I go about that?" in response to "Check the namespaces involved." seems like a pretty weird response if you have learnt about namespaces, which is the kind of fundamental knowledge you need if you want to work on an existing open source project. I would have expected a "aha! I forgot that Sequence could be declared in a namespace, so let me look for it" as your mental response upon reading my reply.

    Likewise, I can understand a mental mixup between Sequence and sequence, but once that was pointed out to you, I would have expected a "aha! I declared a variable named sequence, but I'm calling a function named Sequence, that's why the error message says 'not declared in this scope' rather than complaining about using function call syntax with an unsigned short variable".

    And again, knowing that Sequence was declared in packet.hpp, you would not ask "how do I go about a forward declaration", because an introductory tutorial would have told you that that's what the header file is for.
    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

  5. #20
    Registered User
    Join Date
    Jun 2021
    Posts
    31
    Okay I'm going to try and search namespace with packet.hpp and see if the declaration is within the namespace


    You are exactly right, I have little knowledge when it comes to c++ coding but I'm am learning slowly aha!

    Anyways, I just wanted to say thank you for you're help and knowledge because you have taught me a lot! I'm going to do a c++ full course tutorial or maybe and introductory tutorial like you said and hopefully after that I will have more knowledge and understanding of c++

    Once again thank you for your help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. setw not declared in this scope
    By sprankles in forum C++ Programming
    Replies: 4
    Last Post: 03-13-2011, 07:49 PM
  2. c was not declared in this scope
    By altf4thc in forum C++ Programming
    Replies: 2
    Last Post: 02-15-2010, 01:47 PM
  3. Ďmax_elementí was not declared in this scope
    By Elya in forum C++ Programming
    Replies: 2
    Last Post: 09-14-2009, 10:54 AM
  4. Object not declared in this scope
    By -EquinoX- in forum C++ Programming
    Replies: 1
    Last Post: 08-30-2009, 01:31 AM
  5. Not declared in this scope
    By Taka in forum C++ Programming
    Replies: 45
    Last Post: 03-13-2009, 05:36 AM

Tags for this Thread