CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: 2 Argument Conversion Function

    Quote Originally Posted by Rajesh1978 View Post
    This i did not get from any book or tutorial;
    Sorry, but you cannot learn C++ this way. You are missing the basic fundamentals of C++ if you go on guessing what the language syntax should look like. You must use structured material, whether it is using good books, good tutorials, etc. Otherwise, you'll just throw stuff on the wall, hoping something sticks.
    I thought logically it should work.
    No, it doesn't work this way. Any book will show you right away how to construct objects.
    In the first case when Demo d=100 ( constructor with one argument is called)
    It is same as Demo d(100) ->the 1 argument constructor is called

    likewise Demo d=100,200 should be like Demo d(100,200) and call the 2 argument constructor (it what i thought)
    Throw all of this out the window, it doesn't work. There is something called the comma operator that makes your version uncompilable.

    The way you construct objects is very basic and straightforward:
    Code:
    Demo d(100, 200);
    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; November 26th, 2012 at 05:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured