[C++] Having some troubles with ctors
From: Andrew Falanga (falandr_at_hp.com)
Date: 07/30/04
- Previous message: Edo: "Re: compiling error"
- Next in thread: Mike Wahler: "Re: [C++] Having some troubles with ctors"
- Reply: Mike Wahler: "Re: [C++] Having some troubles with ctors"
- Reply: Alwyn: "Re: [C++] Having some troubles with ctors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Jul 2004 12:15:49 -0600
The subject line is a little too simple, but who wants a long subject
line? Here's what's happeing:
class a {
private:
// got some stuff here
public:
a(std::string s) {
// using s.c_str() to pass to some platform spec.
// functions to fill other data types not given
// because they too go to platform spec stuff,
// specifically TCP/IP related data stuff
}
};
class b {
private:
a objA;
// some other stuff
public:
b (char* str) {
std::string s(str);
a(s);
}
};
So, when I try to compile this I get:
In constructor `b::b(char*)':
error: no match for call to `(a) (std::string&)'
Is this happening because C++, when passing objects, only passes by
reference rather than value? Second, how am I going to get around this?
This isn't the first thing I've tried, but I figured it's time I asked
for help.
Basically, I have to instantiate an object of type "a" when contrusting
an object of type "b". In this case, I need to pass it a character
string representing the hostname of my intended target for connection.
How am I going to pass these strings in such a way that C++ won't complain?
---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.
- Previous message: Edo: "Re: compiling error"
- Next in thread: Mike Wahler: "Re: [C++] Having some troubles with ctors"
- Reply: Mike Wahler: "Re: [C++] Having some troubles with ctors"
- Reply: Alwyn: "Re: [C++] Having some troubles with ctors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|