|
-
April 19th, 2004, 04:19 PM
#1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|