string assignment in constructor?

Hi -

I'm trying to initialize a member string in a class constructor. I used this example:

1
2
3
4
5
6
7
8
int main () 
{
    char *line = "short line for testing";
    
    // with no arguments
    string s1;
    s1 = "Anatoliy";
 


From this web site:

http://anaturb.net/C/string_exapm.htm

but when I do my assignment within the constructor:

fileOutName = "socout.dat";

I get a compiler error "invalid use of member." Am I not permitted to do this assignment within a constructor, or did I do something else wrong?

Thanks...
Did you ever declare fileOutName? Where is your code for all of this?
Aha! Yes, I did declare it, but...as a function by mistake, not an object. It compiles now...thanks.
Topic archived. No new replies allowed.