Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to use stl?

how to use stl?

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studiodebugginghelp
11 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wuren8734
    wrote on last edited by
    #1

    ;)I have writen a program : #include using namespace std; int main() { string a("a"); return 0; } when i compile it then it is the result : --------------------Configuration: abc - Win32 Debug-------------------- Compiling... abc.cpp c:\program files\microsoft visual studio\vc98\include\xstring(600) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\xstring(618) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2629: unexpected 'class std::logic_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2146: syntax error : missing ';' before identifier '_Str' c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: 'string' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: '_Str' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2629: unexpected 'class std::domain_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2629: unexpected 'class std::invalid_argument (' c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2629: unexpected 'class std::length_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2629: unexpected 'class std::out_of_range (' c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2629: unexpected 'class std::runtime_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2334: unexpe

    S T D P 4 Replies Last reply
    0
    • W wuren8734

      ;)I have writen a program : #include using namespace std; int main() { string a("a"); return 0; } when i compile it then it is the result : --------------------Configuration: abc - Win32 Debug-------------------- Compiling... abc.cpp c:\program files\microsoft visual studio\vc98\include\xstring(600) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\xstring(618) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2629: unexpected 'class std::logic_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2146: syntax error : missing ';' before identifier '_Str' c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: 'string' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: '_Str' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2629: unexpected 'class std::domain_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2629: unexpected 'class std::invalid_argument (' c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2629: unexpected 'class std::length_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2629: unexpected 'class std::out_of_range (' c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2629: unexpected 'class std::runtime_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2334: unexpe

      S Offline
      S Offline
      spielehelfer
      wrote on last edited by
      #2

      why dont u use the class CString?

      D S 2 Replies Last reply
      0
      • S spielehelfer

        why dont u use the class CString?

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Because it's an STL exercise. Just because someone gets an error with STL does not automatically warrant a "Use MFC" comment. :rolleyes:


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        1 Reply Last reply
        0
        • W wuren8734

          ;)I have writen a program : #include using namespace std; int main() { string a("a"); return 0; } when i compile it then it is the result : --------------------Configuration: abc - Win32 Debug-------------------- Compiling... abc.cpp c:\program files\microsoft visual studio\vc98\include\xstring(600) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\xstring(618) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2629: unexpected 'class std::logic_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2146: syntax error : missing ';' before identifier '_Str' c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: 'string' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: '_Str' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2629: unexpected 'class std::domain_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2629: unexpected 'class std::invalid_argument (' c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2629: unexpected 'class std::length_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2629: unexpected 'class std::out_of_range (' c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2629: unexpected 'class std::runtime_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2334: unexpe

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          edit your post so that we can see your include btw, include this:

          #include <STRING>


          You don't know where to start ? ask a good friend

          [VisualCalc 3.0][Flags Beginner's Guide]

          B S 2 Replies Last reply
          0
          • W wuren8734

            ;)I have writen a program : #include using namespace std; int main() { string a("a"); return 0; } when i compile it then it is the result : --------------------Configuration: abc - Win32 Debug-------------------- Compiling... abc.cpp c:\program files\microsoft visual studio\vc98\include\xstring(600) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\xstring(618) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2629: unexpected 'class std::logic_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2146: syntax error : missing ';' before identifier '_Str' c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: 'string' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: '_Str' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2629: unexpected 'class std::domain_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2629: unexpected 'class std::invalid_argument (' c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2629: unexpected 'class std::length_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2629: unexpected 'class std::out_of_range (' c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2629: unexpected 'class std::runtime_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2334: unexpe

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            The code you've shown is fine. Something else is at play, like using the /Za compiler switch.


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            1 Reply Last reply
            0
            • T toxcct

              edit your post so that we can see your include btw, include this:

              #include <STRING>


              You don't know where to start ? ask a good friend

              [VisualCalc 3.0][Flags Beginner's Guide]

              B Offline
              B Offline
              BlitzPackage
              wrote on last edited by
              #6

              I agree, it seems as if you forgt an "#include" statement or some needed setting is not set properly.

              1 Reply Last reply
              0
              • W wuren8734

                ;)I have writen a program : #include using namespace std; int main() { string a("a"); return 0; } when i compile it then it is the result : --------------------Configuration: abc - Win32 Debug-------------------- Compiling... abc.cpp c:\program files\microsoft visual studio\vc98\include\xstring(600) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\xstring(618) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2629: unexpected 'class std::logic_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(19) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2146: syntax error : missing ';' before identifier '_Str' c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: 'string' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(29) : error C2501: '_Str' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2629: unexpected 'class std::domain_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(34) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2629: unexpected 'class std::invalid_argument (' c:\program files\microsoft visual studio\vc98\include\stdexcept(45) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2629: unexpected 'class std::length_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(56) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2629: unexpected 'class std::out_of_range (' c:\program files\microsoft visual studio\vc98\include\stdexcept(67) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2629: unexpected 'class std::runtime_error (' c:\program files\microsoft visual studio\vc98\include\stdexcept(78) : error C2334: unexpe

                P Offline
                P Offline
                Pierre Leclercq
                wrote on last edited by
                #7

                It should work. Are you using pre-compiled headers? If so did you put the stdafx.h before the string include?

                1 Reply Last reply
                0
                • T toxcct

                  edit your post so that we can see your include btw, include this:

                  #include <STRING>


                  You don't know where to start ? ask a good friend

                  [VisualCalc 3.0][Flags Beginner's Guide]

                  S Offline
                  S Offline
                  Stephen Hewitt
                  wrote on last edited by
                  #8

                  A small knit pick, but you should use lowercase.

                  Steve

                  T 1 Reply Last reply
                  0
                  • S spielehelfer

                    why dont u use the class CString?

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #9

                    And what does he use if he can't get that to work?

                    Steve

                    1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      A small knit pick, but you should use lowercase.

                      Steve

                      T Offline
                      T Offline
                      toxcct
                      wrote on last edited by
                      #10

                      why ? i always include the standard C++ headers in uppercase, as the include file names are written like that... please explain your feeling


                      You don't know where to start ? ask a good friend

                      [VisualCalc 3.0][Flags Beginner's Guide]

                      S 1 Reply Last reply
                      0
                      • T toxcct

                        why ? i always include the standard C++ headers in uppercase, as the include file names are written like that... please explain your feeling


                        You don't know where to start ? ask a good friend

                        [VisualCalc 3.0][Flags Beginner's Guide]

                        S Offline
                        S Offline
                        Stephen Hewitt
                        wrote on last edited by
                        #11

                        It is standard practice when writing portable code. On some systems, such as Linux, the file system is case sensitive. The standard headers are required to be lowercase.

                        Steve

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups