Why does this constructor-usage not compile ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 16

Thread: Why does this constructor-usage not compile ?

Threaded View

  1. #1
    Join Date
    Apr 2004

    Why does this constructor-usage not compile ?


    assume a simple class like this (string-header has been included and "using namespace std" has been used):

    class someclass
    string m_string;

    someclass(string& str){m_string = str;}

    now I want to use this class in a programm like this

    someclass* cinst = new someclass(string("test"));

    but this doesn't compile without error. have you got any idea why ? the compiler-error occures at the line in the program where I want to instantiate "someclass".

    if I use the following everything works fine:

    string str = "test";

    someclass* cinst = new someclass(str);

    thank you

    Last edited by highhead; April 19th, 2004 at 05:21 PM.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center