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 failed??? [modified]

constructor failed??? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
23 Posts 6 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 ShilpiP

    Is This program working ???

    cout>>x>>endl;
    cin<<ch;

    try using debuging than you find that why x is not giving right output :) #include "stdafx.h" #include <iostream> using namespace std;

    class aa
    {

    public:
    
    	aa(int t = 5)
    	{
    		x = t;
    	}
    	void print()
    	{
    		cout<<x <<endl;
    	
    	}
    private:
    	int x;
    

    };
    int main(int argc, char* argv[])
    {
    aa t;
    t.print();
    cout<<"---------------------"<<endl;

    aa t1(4);
    t1.print();
    char ch;
    cin>>ch;
    
    
    return 0;
    

    }

    Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

    modified on Thursday, June 5, 2008 3:41 AM

    D Offline
    D Offline
    dealon
    wrote on last edited by
    #13

    Thans Shilpi. I'm so sorry.It's my fault. I have edited my post... :)

    If we dream, every thing is possible!

    S 1 Reply Last reply
    0
    • T toxcct

      Shilpi Boosar wrote:

      cout>>x>>endl;cin<<ch;

      you're not serious, are you ? :~ X| when you don't know what you're talking about, please avoid posting crap, that will avoid the question poster to be confused at last.

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      D Offline
      D Offline
      dealon
      wrote on last edited by
      #14

      Sorry toxcct.It's my fault. I have edited my post. Thanks youtoxcct.

      If we dream, every thing is possible!

      1 Reply Last reply
      0
      • D dealon

        Thank you Pallini.I got it... But i found this code can't work. class aa { public: aa():x(5) { }//... }; it said x(5) is not a base class. Thanks once again! :)

        If we dream, every thing is possible!

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

        In my sample

        //...

        was the concise notation for

        aa(int t)
        {
        x = t;
        }
        void print()
        {
        cout << x << endl;
        }
        private:
        int x;
        };

        :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        1 Reply Last reply
        0
        • T toxcct

          Shilpi Boosar wrote:

          cout>>x>>endl;cin<<ch;

          you're not serious, are you ? :~ X| when you don't know what you're talking about, please avoid posting crap, that will avoid the question poster to be confused at last.

          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          S Offline
          S Offline
          ShilpiP
          wrote on last edited by
          #16

          I think now you got the answer why i write that code. :)

          Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

          T D 2 Replies Last reply
          0
          • D dealon

            Thans Shilpi. I'm so sorry.It's my fault. I have edited my post... :)

            If we dream, every thing is possible!

            S Offline
            S Offline
            ShilpiP
            wrote on last edited by
            #17

            Its ok dealon :) He also dont know about this.

            Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

            1 Reply Last reply
            0
            • S ShilpiP

              I think now you got the answer why i write that code. :)

              Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

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

              nope. i still don't understand why you used the wrong operators... cout use <<, not >>

              [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

              S 1 Reply Last reply
              0
              • S ShilpiP

                I think now you got the answer why i write that code. :)

                Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

                D Offline
                D Offline
                dealon
                wrote on last edited by
                #19

                Thank you very much, Shilpi. :)

                If we dream, every thing is possible!

                S 1 Reply Last reply
                0
                • T toxcct

                  nope. i still don't understand why you used the wrong operators... cout use <<, not >>

                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  S Offline
                  S Offline
                  ShilpiP
                  wrote on last edited by
                  #20

                  Actually he write the wrong code and I just do write his wrong code to explain him where he is wrong.:) I just explain him that his code is not working. LOL :laugh:

                  Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

                  1 Reply Last reply
                  0
                  • D dealon

                    Thank you very much, Shilpi. :)

                    If we dream, every thing is possible!

                    S Offline
                    S Offline
                    ShilpiP
                    wrote on last edited by
                    #21

                    Most Welcome :)

                    Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

                    1 Reply Last reply
                    0
                    • C CPallini

                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ ;P ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      toxcct wrote:

                      so no need to flood the thread

                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ ;P ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #22

                      Oh what happend for your thread I give you 5 but I think it needs to repair. :laugh:

                      C 1 Reply Last reply
                      0
                      • H Hamid Taebi

                        Oh what happend for your thread I give you 5 but I think it needs to repair. :laugh:

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

                        Thanks my friend. Anyway I don't bother if people don't appreciate my humour. :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                        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