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. Use of string class in c++

Use of string class in c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++
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.
  • A Offline
    A Offline
    Awantika Singh
    wrote on last edited by
    #1

    My C++ compiler is not accepting string as a predefined class. No objects of string class could be created.

    V S 2 Replies Last reply
    0
    • A Awantika Singh

      My C++ compiler is not accepting string as a predefined class. No objects of string class could be created.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      Do you mean the std::string? Did you add the #include

      1 Reply Last reply
      0
      • A Awantika Singh

        My C++ compiler is not accepting string as a predefined class. No objects of string class could be created.

        S Offline
        S Offline
        Stephane Capo
        wrote on last edited by
        #3

        Hello, some more details would be helpful! Do you mean std::string ? If this is the case did you include ? :

        #include

        then use std::string :

        std::string astring("a string");

        A 1 Reply Last reply
        0
        • S Stephane Capo

          Hello, some more details would be helpful! Do you mean std::string ? If this is the case did you include ? :

          #include

          then use std::string :

          std::string astring("a string");

          A Offline
          A Offline
          Awantika Singh
          wrote on last edited by
          #4

          I've included the header file but "using namespace std" this line is also not working.

          L S C 3 Replies Last reply
          0
          • A Awantika Singh

            I've included the header file but "using namespace std" this line is also not working.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Quote:

            not working.

            What does that mean? Generally speaking: nothing. Please do not expect us to guess what you are doing. Edit your question, show the code you are using, the exact error message that is produced, and which line of code it occurs on.

            1 Reply Last reply
            0
            • A Awantika Singh

              I've included the header file but "using namespace std" this line is also not working.

              S Offline
              S Offline
              Stephane Capo
              wrote on last edited by
              #6

              I agree with other messages, we can not guess everything. My best guess is that you are compiling a C file? (not C++)...

              K 1 Reply Last reply
              0
              • S Stephane Capo

                I agree with other messages, we can not guess everything. My best guess is that you are compiling a C file? (not C++)...

                K Offline
                K Offline
                k5054
                wrote on last edited by
                #7

                Or, he could be using an ancient version of C++, like maybe Borland Turbo C++, that doesn't understand namespaces.

                L 1 Reply Last reply
                0
                • K k5054

                  Or, he could be using an ancient version of C++, like maybe Borland Turbo C++, that doesn't understand namespaces.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  But of course, "not working" could mean anything at all.

                  1 Reply Last reply
                  0
                  • A Awantika Singh

                    I've included the header file but "using namespace std" this line is also not working.

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #9

                    The following code should compile (and run) fine in a decent (i.e. reasonable recent) compiler

                    #include using namespace std;

                    int main()
                    {
                    const string greetings = "Hello world!";
                    cout << greetings << endl;
                    }

                    S 1 Reply Last reply
                    0
                    • C CPallini

                      The following code should compile (and run) fine in a decent (i.e. reasonable recent) compiler

                      #include using namespace std;

                      int main()
                      {
                      const string greetings = "Hello world!";
                      cout << greetings << endl;
                      }

                      S Offline
                      S Offline
                      Stefan_Lang
                      wrote on last edited by
                      #10

                      Try adding #include ;)

                      GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                      C 1 Reply Last reply
                      0
                      • S Stefan_Lang

                        Try adding #include ;)

                        GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                        C Offline
                        C Offline
                        CPallini
                        wrote on last edited by
                        #11

                        There's no need, actually.

                        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