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. Constructor problem

Constructor problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 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.
  • H Offline
    H Offline
    hint_54
    wrote on last edited by
    #1

    How do I implement this?

    tCircle::tCircle( double fNewX, double fNewY, double fNewRadix )

    : cCenter.fX( fNewX     ),
      cCenter.fY( fNewY     ),
      nRadix    ( fNewRadix )
    

    {
    }

    I get the error "error C2059: syntax error : '.'" at "cCenter.fX( fNewX )" regards hint_54 -- modified at 20:24 Friday 14th April, 2006

    G S 2 Replies Last reply
    0
    • H hint_54

      How do I implement this?

      tCircle::tCircle( double fNewX, double fNewY, double fNewRadix )

      : cCenter.fX( fNewX     ),
        cCenter.fY( fNewY     ),
        nRadix    ( fNewRadix )
      

      {
      }

      I get the error "error C2059: syntax error : '.'" at "cCenter.fX( fNewX )" regards hint_54 -- modified at 20:24 Friday 14th April, 2006

      G Offline
      G Offline
      georgeraafat
      wrote on last edited by
      #2

      If your class looks like this: class tCircle { double fX; double fY; double fRadix public: tCircle( double fNewX, double fNewY, double fNewRadix ); }; Constructor implementaiton could be: tCircle::tCircle( double fNewX, double fNewY, double fNewRadix ) : fX( fNewX ), fY( fNewY ), nRadix ( fNewRadix ) {} gmileka

      H 1 Reply Last reply
      0
      • G georgeraafat

        If your class looks like this: class tCircle { double fX; double fY; double fRadix public: tCircle( double fNewX, double fNewY, double fNewRadix ); }; Constructor implementaiton could be: tCircle::tCircle( double fNewX, double fNewY, double fNewRadix ) : fX( fNewX ), fY( fNewY ), nRadix ( fNewRadix ) {} gmileka

        H Offline
        H Offline
        hint_54
        wrote on last edited by
        #3

        No. I have

        class tDot {

        public:
        
        	float	fX, fY;
        

        };

        class tCircle {

        public:
        
        	tCircle( void                );
        	tCircle( float, float, float );
        	tCircle( tDot, float         );
        
        public:
        
        	float		fRadix;
        	tDot		cCenter;
        

        };

        I'm having trouble with the 2nd constructor. Thx ;) hint_54

        G 1 Reply Last reply
        0
        • H hint_54

          No. I have

          class tDot {

          public:
          
          	float	fX, fY;
          

          };

          class tCircle {

          public:
          
          	tCircle( void                );
          	tCircle( float, float, float );
          	tCircle( tDot, float         );
          
          public:
          
          	float		fRadix;
          	tDot		cCenter;
          

          };

          I'm having trouble with the 2nd constructor. Thx ;) hint_54

          G Offline
          G Offline
          georgeraafat
          wrote on last edited by
          #4

          I would add a constructor to tDot. class tDot { public: float fX, fY; tDot(float newfX, float newfY){ fX=newfX; fY=newFY; }; }; class tCircle { public: tCircle( void ); tCircle( float, float, float ); tCircle( tDot, float ); public: float fRadix; tDot cCenter; }; tCircle::tCircle(double newX, double newY) : cCenter( newX, newY) { } gmileka

          H 1 Reply Last reply
          0
          • H hint_54

            How do I implement this?

            tCircle::tCircle( double fNewX, double fNewY, double fNewRadix )

            : cCenter.fX( fNewX     ),
              cCenter.fY( fNewY     ),
              nRadix    ( fNewRadix )
            

            {
            }

            I get the error "error C2059: syntax error : '.'" at "cCenter.fX( fNewX )" regards hint_54 -- modified at 20:24 Friday 14th April, 2006

            S Offline
            S Offline
            Saurabh Garg
            wrote on last edited by
            #5

            You should either use cCenter(fNewX, fNewY), assuming tDot have a constructor accepting two arguments or move cCenter.fX and cCenter.fY within the function body. -Saurabh

            H 1 Reply Last reply
            0
            • S Saurabh Garg

              You should either use cCenter(fNewX, fNewY), assuming tDot have a constructor accepting two arguments or move cCenter.fX and cCenter.fY within the function body. -Saurabh

              H Offline
              H Offline
              hint_54
              wrote on last edited by
              #6

              thx ;) hint_54

              1 Reply Last reply
              0
              • G georgeraafat

                I would add a constructor to tDot. class tDot { public: float fX, fY; tDot(float newfX, float newfY){ fX=newfX; fY=newFY; }; }; class tCircle { public: tCircle( void ); tCircle( float, float, float ); tCircle( tDot, float ); public: float fRadix; tDot cCenter; }; tCircle::tCircle(double newX, double newY) : cCenter( newX, newY) { } gmileka

                H Offline
                H Offline
                hint_54
                wrote on last edited by
                #7

                That's it! thx ;) hint_54

                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