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. Problem with CPP Statement

Problem with CPP Statement

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcsharphtmldata-structures
8 Posts 4 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.
  • S Offline
    S Offline
    Semion_N
    wrote on last edited by
    #1

    Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error: error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion) Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)

    SnaidiS(Semion)

    W G J 3 Replies Last reply
    0
    • S Semion_N

      Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error: error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion) Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)

      SnaidiS(Semion)

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #2

      Your declaration of the array is the problem.

      Tic_Tac_Toe *PointersToNodes;
      ...
      PointersToNodes=new Tic_Tac_Toe[9];

      It is not an array of pointers, but an array of objects. For each Tic_Tac_Toe, you are calling the constructor. try this

      Tic_Tac_Toe **PointersToNodes;
      ...
      PointersToNodes=new Tic_Tac_Toe* [9];

      S 1 Reply Last reply
      0
      • S Semion_N

        Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error: error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion) Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)

        SnaidiS(Semion)

        G Offline
        G Offline
        Gary R Wheeler
        wrote on last edited by
        #3

        The left side of your assignment statement expects a value of type Tic_Tac_Toe, while your member function buildNewTree returns a pointer to a value of type Tic_Tac_Toe.


        Software Zen: delete this;

        Fold With Us![^]

        S 1 Reply Last reply
        0
        • W Waldermort

          Your declaration of the array is the problem.

          Tic_Tac_Toe *PointersToNodes;
          ...
          PointersToNodes=new Tic_Tac_Toe[9];

          It is not an array of pointers, but an array of objects. For each Tic_Tac_Toe, you are calling the constructor. try this

          Tic_Tac_Toe **PointersToNodes;
          ...
          PointersToNodes=new Tic_Tac_Toe* [9];

          S Offline
          S Offline
          Semion_N
          wrote on last edited by
          #4

          Oh my... Thank you! alot :-D

          SnaidiS(Semion)

          W 1 Reply Last reply
          0
          • S Semion_N

            Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error: error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion) Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)

            SnaidiS(Semion)

            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #5

            Do you by any chance take the same C++ class as SwatiPathania? (see post just beneath yours) :rolleyes:

            -- Torn from tomorrow's headlines

            S 1 Reply Last reply
            0
            • S Semion_N

              Oh my... Thank you! alot :-D

              SnaidiS(Semion)

              W Offline
              W Offline
              Waldermort
              wrote on last edited by
              #6

              You are very much welcome. It is nice to here a thankyou around here for a change ;0)

              1 Reply Last reply
              0
              • G Gary R Wheeler

                The left side of your assignment statement expects a value of type Tic_Tac_Toe, while your member function buildNewTree returns a pointer to a value of type Tic_Tac_Toe.


                Software Zen: delete this;

                Fold With Us![^]

                S Offline
                S Offline
                Semion_N
                wrote on last edited by
                #7

                ah Ok I got it thank you!:)

                SnaidiS(Semion)

                1 Reply Last reply
                0
                • J Jorgen Sigvardsson

                  Do you by any chance take the same C++ class as SwatiPathania? (see post just beneath yours) :rolleyes:

                  -- Torn from tomorrow's headlines

                  S Offline
                  S Offline
                  Semion_N
                  wrote on last edited by
                  #8

                  OMG SwatiPathania have no class he just starts like I see but he can use mine :) if he wants. lol it's just a huge coincidence. It's no way! X| :-D

                  SnaidiS(Semion)

                  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