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
    Posts
    20

    Why does this constructor-usage not compile ?

    Hi,

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

    class someclass
    {
    private:
    string m_string;

    public:
    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

    highhead
    Last edited by highhead; April 19th, 2004 at 04: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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center